How to Perform Hardware Audit Using WMI Commands and Tools

This article explains how to perform hardware audit of the local or remote Windows PCs using WMI. It shows how to use WMI queries to extract various hardware inventory info.

Starting from Windows XP and Windows 2003 Windows Management Instrumentation Command-line (WMIC) is a primary interface for performing hardware audit and executing other Windows management actions. WMIC extends WMI for operation from several command-line interfaces and through batch scripts. Before WMIC, you have to have a programming experience to use WMI, but do-it-yourself systems management with WMI was difficult. WMIC changes this situation by giving you a powerful, user-friendly interface to the WMI namespace. Hardware audit with WMIC is more intuitive then WMI and is the recommended approach if you prefer to make audit operation from the command line.

Getting a Hardware Audit Information Using WMI

You can use WMIC in the interactive mode by typing wmic in the Windows command prompt, Telnet session or Run dialog box. In this case you will be prompted to enter WMI audit and management commands interactively. After the command runs, the WMIC command prompt reappears. WMIC also runs in noninteractive mode. This mode is especially useful when you need to complete a single task or you need to run WMIC commands in a batch file. For, example type the following command to audit processors on the local PC.

wmic cpu

By running this command you will get all available inventory information about CPU that includes few dozens of fields. If you are looking to get particular fields you can specify them as parameters.

wmic cpu get Description, NumberOfCores

By default WMIC command shows collected audit information on the console screen. If order to have it in a file you can redirect command output. You can use a special option that defines a preferred output format. For example, the following command reports data in CSV format and stores them in a file.

wmic cpu get Description, NumberOfCores /format:csv > hardware-audit.csv

Collecting Hardware Audit Information from Remote PCs

By default WMIC reports software and hardware audit data for the local PC, i.e. the PC where audit commands are executed. If you like to extract audit information from a remote PC, you need to specify its name as a parameter. For example, the command below collects CPU information from the REMOTE-PC-1 computer.

wmic /node:<REMOTE-PC-1> cpu get Description, NumberOfCores

In order to collect software and hardware audit information from remote computers you need to have an administrative access. Also you need to enable WMI on every computer in order to get information from it using WMIC and make sure that RPC infrastructure works correctly and isn't blocked by firewalls.

If you need to collect hardware inventory information using WMI from multiple remote PCs, you can write batch scripts, VisualBasic scripts or PowerShell scripts in order to collect inventory information from every remote PC iteratively and output data to a file.

Alternative Hardware Audit Solutions

The main disadvantage of using WMI as a hardware audit solution is that it's pretty complicated. You have to write scripts if you need to collect inventory information from all network PCs and refer the documentation to learn how to audit different hardware assets. If you prefer to use all-in-one solution, you can try a network inventory software, that is able to perform software and hardware audit of all computers across a local network, and show the collected data in easy form on a screen or prepare printable software audit and hardware audit reports.

Useful Resources
  • WMI Reference contains information about infrastructure that provides an access to software and hardware inventory information on Windows-based operating systems.
  • Microsoft Script Center is aimed to educate network administrators how to use Windows PowerShell and other scripting solutions to perform audit, inventory, management and other administrative tasks.