WMI is a great and simple way of gathering information about computers. For example, it’s a snap to determine the type of computer you are on:
$info = (Get-CimInstance -ClassName win32_computersystem).PCSystemType $info
Unfortunately, often WMI properties return cryptic numbers instead of friendly text, so when you are running above code on a laptop, you get back a “2”, and when you get back other numbers, you will have to google to find out what the numbers stand for.
Once you figured codes out, there is a simple and efficient way in PowerShell to convert numbers to friendly text using enumerations:
enum ServerTypes { Unspecified Desktop Mobile Workstation EnterpriseServer SOHOServer AppliancePC PerformanceServer Maximum } [ServerTypes]$info = (Get-CimInstance -ClassName win32_computersystem).PCSystemType $info
Enumerations tie friendly text to code numbers and by default start with 0. Above enumeration assigns “Unspecified” to code 0, and code 2 will be represented as “Mobile”.
By assigning the enum type [ServerTypes] to your result variable, all translating is performed automatically, and cryptic code numbers now show as friendly text.
Since ID numbers are evolving constantly, you may eventually run into new code numbers and have to expand the enumeration.