A simple function to display all the properties of a
PowerShell object and its values!
FUNCTION
Display-AllProperties{
Param($ObjectIn,[Switch]$Display)
[System.Array]$Properties = @()
($ObjectIn | gm) | Foreach{ If ($_.MemberType
-eq "Property"){ $Properties += $_.Name } }
[System.Object]$Output = @{}
[Int]$Index = 1
Foreach ($Object in $ObjectIn){
[System.Object]$Output.$Index = @{}
$Properties | Foreach{
$Output.$Index.$_ = $Object.$_
If($Display){ Write-Host ("$_ =
" + [String]($Object.$_)) }
}
If($Display){ Write-Host }
$Index ++
}
If(!$Display){ $Output }
}
Comments
Post a Comment