Skip to content

Instantly share code, notes, and snippets.

@chrisbrownie
Created August 3, 2017 05:40
Show Gist options
  • Save chrisbrownie/ca46d9d3fae8bc1a6f20eab2272ac410 to your computer and use it in GitHub Desktop.
Save chrisbrownie/ca46d9d3fae8bc1a6f20eab2272ac410 to your computer and use it in GitHub Desktop.
Returns only properties that have values
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