Managing with WMI
Posted on 12 Jul 2007 at 17:52
Thomas Lee rounds off the basics of .NET by examining how Windows Management Instrumentation can be used in effective systems management.
Windows Management Instrumentation (WMI) is a great Microsoft technology that can help you to manage your systems better: it's equally useful for developers, enabling them to expose the management aspects of their applications. In this column, I'll examine what WMI is, its architecture and how you use it. And, as in most of my recent columns, I'll present PowerShell examples to illustrate. Strictly speaking, WMI isn't part of the .NET Framework, but accessing WMI objects is so like accessing other .NET objects that it's easy to use alongside other .NET components.
Before delving into the details, a tip of the hat to Austin Osuide, who gave an excellent talk on WMI at the May UK PowerShell user group. His enthusiasm for WMI (and, of course, for PowerShell) convinced me this was a good topic for this column, and I have his slides should any reader want them.
What is WMI?
WMI is Microsoft's implementation of the DTMF's (Desktop Management Task Force) Web Based Enterprise Management and CIM (Common Information Model), and as such it provides non-proprietary and environment-independent mechanisms for manipulating information on all components of a computer system. WMI allows you to monitor and control just about all the computing resources throughout your corporate network, including hardware like batteries, BIOS, disk drives and network cards. You can use WMI to manage processes, services, shares, Registry settings, event logs, users, groups and more. WMI can also detect events as they occur (say, when a service has stopped) and notify a WMI Event consumer.
WMI is built into all versions of Windows 2000 and above, and can be installed on any other 32-bit Windows client. Prior to WMI, if you wanted access to the information and functions it delivers, you'd have had to write Win32 API calls using C++, as these calls typically weren't available to scripting languages.
The WMI architecture has three main components:
WMI providers (and managed objects) - COM objects that give access to managed objects. A managed object is a computer component such as a process, a hard drive and so on.
WMI infrastructure - core OS components that provide consistent access to WMI-managed objects.
WMI consumers - management applications or scripts that interact with the infrastructure to make use of the provider objects.
Several providers are implemented by default in the OS (see www.pcpro.co.uk/links/155dotnet1 for more information on the WMI providers implemented in Windows). For example, in Windows XP, the Win32 provider is installed by default, while you can optionally install the SNMP provider via Control Panel's Add/Remove programs applet. Other applications, such as Office Communications Server 2007, supply additional WMI classes and make use of WMI to access this information. Increasingly, Microsoft applications are WMI enabled, both supplying WMI classes and making use of them.
WMI classes are similar to any of the other .NET classes I've illustrated in past columns, and like these they offer methods you can call and properties you can retrieve and set. The only significant difference is the method of instantiating individual classes. There are 954 classes on my Windows XP SP2 laptop, while on one of my Windows Server 2003 systems there are 882, and on my Longhorn Beta 3 virtual machine there are 1,003: some of these are WMI system classes (53 of them on my XP system). A WMI provider consists of a DLL file containing its code and a Managed Object Format (MOF) file that defines the classes for which this provider returns data and performs operations. System classes have class names that start with two underscore characters, for example __Event, and tend not to be of use to IT administrators. On the other hand, the Win32 provider supports 564 classes that are of interest to IT pros.
- Headings vs headers: how to use both in Word
- Windows Server 2012 R2: how the Datacenter edition could change SMBs
- Invoices and VAT: how to set up your documents correctly
- Nexus 5 vs Samsung Galaxy S4 Active: the best phone for avoiding screen burn
- How much is a social user worth?
- The key to choosing a secure password
- Thunderbolt Bridge: a fast Mac migration tool
- Should you advertise on Twitter?
- How to track a lost smartphone
- Self-publishing success: the best way to sell your book
- Quickest way to upload 1GB? Hop on a train
- Move over Delia: IBM Watson is cooking tonight
- Eric Schmidt on the double-edged smartphone: friend and foe
- Getty joins the race to the bottom
- Hour of Code: five steps to learn how to code
- Sony Xperia Z2 Tablet review: first look
- Sony Xperia Z2 review: first look
- Samsung Galaxy Gear 2 review: first look
- Nokia XL review: first look
- Samsung Galaxy S5 review: first look
- IDC: iPad intertia opens door for Windows tablets
- Office 365 goes social with "Oslo" news feed
- Windows XP: upgrading 30,000 PCs in 30 days
- LibreOffice: ignore Microsoft's "nonsense" on government's open source plans
- Intel Xeon E7 v2 servers support 6TB of RAM
- Microsoft promises video calls between Skype and Lync
- Office for iPad due before July
- Windows 7 on business PCs gets an extension
- Windows apps land on Chromebooks with VMware
- Office 365 gets two-factor authentication