Private/ConvertTo-Hashtable.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Function ConvertTo-Hashtable {
    Param (
        [Parameter(Mandatory,ValueFromPipeline)]
        [PSObject[]] $Object
    )
    Process {
        foreach ($obj in $Object) {
            $ht = [ordered]@{}
            $obj | Get-Member -MemberType *Property | ForEach-Object {
                $ht.($_.Name) = $obj.($_.Name)
            }
            $ht
        }
    }
}