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.

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 = ...

Get Active Directory, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.