26.4 WMI Tools

There are several tools available to query and browse WMI information. These tools can be very useful in situations in which you want to access WMI information but do not want to write a script to do it.

26.4.1 WMI from a Command line

The WMI command-line tool (WMIC) is a powerful tool that can expose virtually any WMI information you want to access. It is available in Windows XP and Windows Server 2003. Unfortunately, WMIC does not run on Windows 2000, but it can still be used to query WMI on a Windows 2000 machine.

WMIC maps certain WMI classes to "aliases." Aliases are used as shorthand so that you only need to type "logicaldisk" instead of "Win32_LogicalDisk". An easy way to get started with WMIC is to type the alias name of the class you are interested in. A list of all the objects that match that alias/class will be listed.

wmic:root\cli>logicaldisk list brief
DeviceID  DriveType  FreeSpace    ProviderName  Size         VolumeName
A:        2
C:        3          1540900864                 4296498688   W2K
D:        3          15499956224                15568003072
Z:        5          0                          576038912    NR1EFRE_EN

Most aliases have a list brief subcommand that will display a subset of the properties for each object. You can run similar queries for services, CPUs, processes, and so on. For a complete list of the aliases, type alias at the WMIC prompt.

The creators of WMIC didn't stop with simple lists. You can also utilize WQL to do more complex queries. This next example displays all logical disks with a drivetype of 3 (local hard drive):

wmic:root\cli>logicaldisk where (drivetype = '3') list brief
DeviceID  DriveType  FreeSpace    ProviderName  Size         VolumeName
C:        3          1540806144                 4296498688   W2K
D:        3          15499956224                15568003072

We have just touched the surface of the capabilities of WMIC. You can invoke actions, such as creating or killing a process or service, and modify WMI data through WMIC as well. For more information, check out the Support WebCast "WMIC: A New Approach to Managing Windows Infrastructure from a Command Line," available at http://support.microsoft.com/default.aspx?scid=/webcasts/. Help information is also available on Windows XP and Windows Server 2003 computers by going to Start Help, and search on WMIC.

26.4.2 WMI from the Web

Included as sample applications with the original WMI SDK, the WMI CIM Studio and WMI Object browser are web-based applications that provide much more benefit than just being example applications provided in the SDK. The following is a list of the tools and their purpose:

  • The WMI CIM Studio is a generic WMI management tool that allows you to browse namespaces, instantiate objects, view the instances of a class, run methods, edit properties, and even perform WQL queries.

  • The WMI Object Browser allows you to view the properties for a specific object, look at the class hierarchy, view any associations, run methods, and edit properties for an object.

  • The WMI Event Registration allows you to create, view, and configure event consumers.

  • The WMI Event Viewer displays events of configured event consumers.

The web-based WMI tools can be obtained separately from the WMI SDK at: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=6430F853-1120-48DB-8CC5-F2ABDC3ED314.

26.4.3 WMI SDK

The WMI SDK provides the complete WMI reference documentation along with numerous sample scripts and programs. It also includes the web-based WMI tools described in the previous section. The WMI SDK can be downloaded from the Platform SDK site located at http://www.microsoft.com/msdownload/platformsdk/sdkupdate/default.htm.

    Part II: Designing an Active Directory Infrastructure
    Part III: Scripting Active Directory with ADSI, ADO, and WMI