Rob van der Woude's Scripting Pages

WMI Queries for Hardware

The following table lists a collection of WMI classes and queries that can be useful for hardware inventories.

 

Hardware Type WMI Remarks
Namespace Class Filter
BIOS root/CIMV2 Win32_BIOS    
CPU root/CIMV2 Win32_Processor    
Harddisk root/CIMV2 Win32_DiskDrive   Physical disks
Win32_DiskDriveToDiskPartition   Partitions on disks
Win32_DiskPartition   Partitions
Win32_LogicalDisk   Volumes
Win32_LogicalDiskToPartition   Volumes in partitions
Harddisk Controller root/CIMV2 Win32_IDEController   IDE & SATA
Win32_SCSIController   SCSI & SATA
Keyboard root/CIMV2 Win32_Keyboard   Keyboard type, layout, function keys
root/WMI MSKeyboard_PortInformation   Function keys, indicators, connector
Main Board root/CIMV2 Win32_BaseBoard    
Memory root/CIMV2 Win32_PhysicalMemory   Memory hardware
Monitor root/CIMV2 Win32_DesktopMonitor   Screen resolution (desktop monitor only)
root/WMI WmiMonitorID Instances of these classes can be linked by their shared InstanceName property Manufacturer, serial number
WmiMonitorBasicDisplayParams Physical screen size, video inputs
Mouse root/WMI MSMouse_PortInformation   Mouse type, buttons, connector
Network Adapter root/CIMV2 Win32_NetworkAdapter MACAddress IS NOT NULL Windows XP
PhysicalAdapter=TRUE Windows 7..10
Optical Disk root/CIMV2 Win32_CDROMDrive    
Parallel Port root/CIMV2 Win32_ParallelPort    
Printer root/CIMV2 Win32_Printer Network=TRUE Network printers
Local=TRUE Local printers
Local=TRUE AND NOT PrintProcessor='winprint' Local physical printers
Serial Port root/CIMV2 Win32_SerialPort    
Sound root/CIMV2 Win32_SoundDevice NOT Manufacturer='Microsoft'  
System Slot root/CIMV2 Win32_SystemSlot SlotDesignation LIKE 'PCI%' PCI* slots
SlotDesignation LIKE 'AGP%' AGP slots
USB Port root/CIMV2 Win32_USBController   All USB ports
Name LIKE '%USB 3%' USB 3 ports
Video root/CIMV2 Win32_VideoController    

 

 

Using These WMI Queries

To use these queries in scripts, download and start WMIGen, select the appropriate namespace (root/CIMV2 in most cases), and scroll to the appropriate class, e.g. Win32_Printer.

Select the scripting language you want to use, e.g. "Batch", and click the "Generate" button to generate the code.

The main line of code of the generated example is:

WMIC.EXE /Node:"%Node%" Path Win32_Printer Get /Format:Value

Add a filter from the table, if required, and limit the output to a single property or selection of properties, instead of all properties:

WMIC.EXE /Node:"%Node%" Path Win32_Printer Where "Local=TRUE AND NOT PrintProcessor='winprint'" Get DriverName /Format:Value

Save the modified script, run it, and you will get a list of locally installed physical printers:

DriverName=Canon iP4700 series


DriverName=HP LaserJet P2050 Series PCL6

 

 

More to Explore

Read the source code of Hardware.hta for detailed examples of hardware inventory queries (not for the faint of heart).


page last uploaded: 2018-11-13, 10:56