WMI can retrieve a lot more object instances than you might think. If you submit a parent class, Get-WmiObject returns all instances of all derived classes. That’s why a simple line like the following can get you all hardware-related instances:
PS> Get-WmiObject -Class CIM_PhysicalElement | Group-Object -Property __Class
Count Name
—– —-
1 Win32_OnBoardDevice
1 Win32_PhysicalMemoryArray {\\DEMO5\root\cimv2:Win32_
3 Win32_PortConnector
1 Win32_BaseBoard
1 Win32_SystemSlot
2 Win32_PhysicalMemory
1 Win32_SystemEnclosure
4 Win32_PhysicalMedia
You can turn this into a lookup tool. Here’s how:
PS> $col1 = @{Name=‘Key’; Expression={ ($_.__Class.ToString() -split ‘_’)[–1] }}
PS> $info = Get-WmiObject -Class CIM_PhysicalElement | Select-Object *, $col1 | Group-Object -Property Key -AsHashTable -AsString
Use it like this:
PS> $info
Name
—-
SystemEnclosure
OnBoardDevice
PhysicalMemory {@{__GENUS=2; __CLASS=Win32_PhysicalMemory; _…
PhysicalMedia
SystemSlot
BaseBoard
PortConnector
PhysicalMemoryArray {@{Status=; Name=Physical Memory Array; Repla…
PS> $info.baseboard
(…)
PS> $info.OnboardDevice
(…)
PS> $info.PhysicalMemory
(…)