Let’s assume you want to hide all object properties that have no value (are empty). Here is a simple approach:
# get any object $object = Get-Process -Id $pid # try and access the PSObject $propNames = $object.PSObject.Properties.Where{$null -ne $_.Value}.Name $object | Select-Object -Property $propNames
This will output only the properties that have a value. You could even make sure the properties are sorted:
# get any object $object = Get-Process -Id $pid # try and access the PSObject $propNames = $object.PSObject.Properties.Where{$null -ne $_.Value}.Name | Sort-Object $object | Select-Object -Property $propNames