Skip to content

Instantly share code, notes, and snippets.

@SeidChr
Created October 6, 2022 14:38
Show Gist options
  • Save SeidChr/80c350f9ba5f1e2a36c020ac86a416d0 to your computer and use it in GitHub Desktop.
Save SeidChr/80c350f9ba5f1e2a36c020ac86a416d0 to your computer and use it in GitHub Desktop.
filter To-Select {
$object = $_
$type = $_.GetType()
if ($type -in [hashtable],[pscustomobject]) {
$properties = ([pscustomobject] $_).psobject.properties
$propNames = $properties.name
if (-not ("Name" -in $propNames -and "Expression" -in $propNames)) {
$object = $properties | ForEach-Object {
@{
Name = $_.name
Expression = $_.value
}
}
}
}
return $object
}
Get-Process | Select -First 2 -Property ('Name', @{ 'IncrementalId' = { $_.ID + 5 }; BasePrio = { $_.BasePriority * 1000 } } | To-Select)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment