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.
- How to add in-app purchasing to an iPhone, Android or Windows app
- Remote-control ransomware: TeamViewer and software hardball
- Why laptops with serial ports matter to the Internet of Things
- Make your mobile battery last longer
- Small steps into handling Big Data
- Nexus 5: does it really run stock Android?
- How to get broadband to a garden office
- How to write your company's IT security policy
- Raspberry Pi and Wolfram: a must-have for every child
- Could you get by with Office Web Apps?
- How Google Glass ruined my lunch hour
- Smartphone battery packs: can a USB power pack beat the festival battery blues?
- Windows Easy Transfer – not so "easy" in Windows 8.1
- Formula 1: what a difference virtualisation makes
- Office of the future: comfy chairs and tablets everywhere
- I went to Glastonbury and the only thing that got high was my smartphone
- Meet the robots helping teach children
- PaperLater: would you pay to print the internet?
- Amazon vs Kobo: how much to make the ebook switch?
- Phishing emails: how I nearly got caught out
- Will the next Windows 8.1 update arrive next month?
- BT One Phone lets SMBs ditch landlines for mobiles
- Microsoft shows Modern apps running in desktop windows
- Apple and IBM buddy up for enterprise push
- Windows Phone 8.1 starts rolling out to Nokia phones
- Government broadband plans "lack ambition"
- SMBs get Office 365 price cuts, new plans
- Windows 7: you can keep it until 2020
- BlackBerry Passport's square for spreadsheets
- Microsoft to release six updates this Patch Tuesday