WMI and Get-CimInstance can provide you with a lot of useful information but the returned objects often contain a number of empty properties:

PS> Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -Property 

Also, properties aren’t necessarily sorted. You can fix both by identifying and sorting the properties that are not empty:

# get all WMI information
$os = Get-CimInstance -ClassName Win32_OperatingSystem
# find names of non-empty properties
$filledProperties = $os.PSObject.Properties.Name.Where{![string]::IsNullOrWhiteSpace($os.$_)} | Sort-Object
# show non-empty properties only
$os | Select-Object -Property $filledProperties

Twitter This Tip! ReTweet this Tip!