Skip to content

Instantly share code, notes, and snippets.

@Proxx
Last active February 24, 2016 09:01
Show Gist options
  • Save Proxx/33755cfe3dec95e72b51 to your computer and use it in GitHub Desktop.
Save Proxx/33755cfe3dec95e72b51 to your computer and use it in GitHub Desktop.
Function Select-Properties {
Param(
[Parameter(ValueFromPipeline)]
$InputObject,
[Switch] $AsPSObject,
[Switch] $ReturnNames
)
if ($AsPSObject)
{
$Properties = $InputObject.PSObject.Properties | Select-Object Name, Value
}
else
{
$Properties = $InputObject | Get-Member -MemberType Properties
}
$Selection = $Properties | Out-Gridview -PassThru | Select-Object -ExpandProperty Name
if ($ReturnNames) { $Selection }
else { $InputObject | Select-Object -Property $Selection }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment