Skip to content

Instantly share code, notes, and snippets.

@HerbM
Created May 9, 2018 15:44
Show Gist options
  • Save HerbM/00cb281bc7c992e3ad722edfa5ee0895 to your computer and use it in GitHub Desktop.
Save HerbM/00cb281bc7c992e3ad722edfa5ee0895 to your computer and use it in GitHub Desktop.
Function Get-Property {
[CmdletBinding()]param(
[Parameter(ValueFromPipeline)][psobject]$object,
[switch]$AsHash
)
Process {
If ($AsHash) {
$Property = [ordered]@{}
$Object.psobject.get_properties() | ForEach-Object {
$Property += @{ $_.Name = $_.Value }
}
$Property
} else {
$Object.psobject.get_properties()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment