All Versions
WMI classes are inherited from each other, and that’s something you can take advantage of. Take this line:
PS> Get-WmiObject -Class Win32_Printer
It will return all printers found by WMI. Printers are inherited from more generic classes, and this shows the inheritance tree:
PS> Get-WmiObject -Class Win32_Printer | Select-Object -ExpandProperty __derivation -First 1 CIM_Printer CIM_LogicalDevice CIM_LogicalElement CIM_ManagedSystemElement
So if you are not specifically interested in printers, but rather more widely on hardware, choose a more generic parent class, like CIM_LogicalDevice. This will give you a complete hardware inventory in just one line:
PS> Get-WmiObject -Class CIM_LogicalDevice Manufacturer Name Status StatusInfo ------------ ---- ------ ---------- Realtek Realtek High Def... OK 3 Kona OK Intel Corporation Intel(R) 8 Serie... OK Intel Corporation Intel(R) Wireles... Microsoft Microsoft Kernel... ASIX AX88772B US... Microsoft Virtueller Micro... Microsoft Bluetooth-Gerät ... Microsoft Microsoft-ISATAP... Microsoft-ISATAP... Microsoft Teredo Tunneling... Microsoft Von Microsoft ge... Microsoft-ISATAP... Microsoft-ISATAP... Microsoft-ISATAP... Microsoft-ISATAP... ASIX AX88772B US... Microsoft-ISATAP... Microsoft-ISATAP... Virtueller Micro... Microsoft-ISATAP... Microsoft-ISATAP... Microsoft-ISATAP... -Virtual Battery 0- CRB Battery 0 (...)
And this will return the classes involved, so you get a good overview of how WMI calls your hardware types:
PS> Get-WmiObject -Class CIM_LogicalDevice | Group-Object -Property __Class -NoElement Count Name ----- ---- 1 Win32_SoundDevice 1 Win32_Battery 1 Win32_IDEController 20 Win32_NetworkAdapter 1 Win32_PortableBattery 10 Win32_Printer 1 Win32_Processor 2 Win32_DiskDrive 7 Win32_DiskPartition 1 Win32_Fan 2 Win32_Keyboard 5 Win32_LogicalDisk 2 Win32_MappedLogicalDisk 1 Win32_MemoryArray 2 Win32_MemoryDevice 2 Win32_PointingDevice 1 Win32_SCSIController 2 Win32_USBController 6 Win32_USBHub 5 Win32_Volume 4 Win32_CacheMemory 1 Win32_DesktopMonitor 1 Win32_VideoController 1 Win32_VoltageProbe 1 Win32_MotherboardDevice 8 Win32_Bus 134 Win32_PnPEntity
It basically takes all the instances derived from CIM_LogicalDevice and groups them by “__Class” which is their real class name.