Created
August 3, 2017 05:40
-
-
Save chrisbrownie/ca46d9d3fae8bc1a6f20eab2272ac410 to your computer and use it in GitHub Desktop.
Returns only properties that have values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function OnlyWithValues { | |
PROCESS { | |
$properties = $_ | Get-Member | Select -ExpandProperty Name | |
$output = @{} | |
foreach ($property in $properties) { | |
if (-not ([String]::IsNullOrEmpty($_.$property))) { | |
$output[$property] = $_.$Property | |
} | |
} | |
return $output | |
} | |
} | |
Get-ChilDItem | OnlyWithValues |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment