Home > Articles > Operating Systems, Server > Microsoft Servers

  • Print
  • + Share This
This chapter is from the book

Windows Management Instrumentation (WMI)

WMI was available in Windows 2000, but there was no user-level interface. Programs had to be created to take advantage of the data exposed by WMI APIs. Windows XP and Windows Server 2003 provide an interface called WMIC. WMI is a very powerful tool that has endless possibilities, and with WMIC, it is readily available. For a quick introduction to WMI and WMIC, go to a Windows XP client (perhaps your laptop or office desktop), go to a command prompt, and enter WMIC. You will get a message that WMIC is being installed and it might take a minute or two. You can now execute WMI commands that heretofore required a program to call the APIs. After WMIC installs, you'll get a wmic:root\cli prompt (referred to here simply as "the WMIC prompt"). Here are some introductory commands you can play with:

  • /?: Online help (many screens of these; paused at each page).

  • OS: Operating system info (name, build, and so on).

  • NIC: Network Interface Controller info (adapters, type, version, and so on).

  • NTDOMAIN: Domain information (domain name, site name, DC name and address).

  • PAGEFILE: Pagefile data (current usage, location, peak usage).

  • IRQ: IRQ assignments, including a status of each.

  • QFE: Be careful! This lists all the hotfixes, security updates, and so on installed on the system, which is quite a lengthy list on most systems.

Beyond the basics, there are WMI service providers that permit you to gather information about the Windows infrastructure, such as AD and DNS. You can execute some fairly complex commands to extract information. My first introduction to WMI was by a colleague, Frank Blando, who authored Chapter 13, "High Availabiltiy in Windows Server 2003," and the "Windows Management Instrumentation (WMI)" section of Chapter 10 of this book. In his demo, Frank had concocted a very long WMI command and executed it. This command ran the Cluster Administrator, extracted information from it, formatted it in HTML format, saved the HTML file to the wwwroot directory, and then refreshed the data every five minutes. He could then use a browser to view the cluster data. Setting this up on an internal or even an external server would allow you to monitor cluster events without messing with the snap-in and event logs. It was quite impressive.

Realize that these APIs are the same ones called by any other tool, but now you have some easy ways of customizing them. Some of the available providers include

  • Active Directory Provider: MicrosoftActiveDirectory

  • Trust Health Provider: MicrosoftHealthMonitor

  • DNS Provider: MicrosoftDNS

  • Cluster: MSCluster

A more extensive description and code samples are provided in Chapter 10.

  • + Share This
  • 🔖 Save To Your Account