Functions/Data/Convert-PSObjectToHashTable.ps1

Function Convert-PSObjectToHashTable
    {
    [cmdletbinding()]
    Param
        (
        [Parameter(Mandatory=$true,ValueFromPipeline=$true)]
        [psobject]
        $PSObject,

        [Parameter(Mandatory=$false)]
        [Boolean]
        $Ordered = $True
        )
    Process
        {
        # Instantiate New Hash Table
        $HashTable = if($ordered){[ordered]@{}}else{@{}}

        # Fill Hash Table from the psobject property data
        $PSObject.psobject.properties | Foreach { $HashTable[$_.Name] = $_.Value }
        
        # Out Hash Table
        $HashTable
        }
    }