Functions/Internal/ConvertTo-OrderedHashtableFromPSCustomObject.ps1

function ConvertTo-OrderedHashtableFromPSCustomObject { 
    param ( 
        [Parameter(  
            Position = 0,   
            Mandatory = $true,   
            ValueFromPipeline = $true,  
            ValueFromPipelineByPropertyName = $true  
        )] [object] $psCustomObject 
    );
    # Write-Verbose "[Start]:: ConvertTo-OrderedHashtableFromPSCustomObject"
process{
    $output = [ordered]@{}; 
    $psCustomObject | Get-Member -MemberType NoteProperty | 
    ForEach-Object {
        $output.($_.name) = $psCustomObject.($_.name); 
    } 
    
    # Write-Verbose "[Exit]:: ConvertTo-OrderedHashtableFromPSCustomObject"

    return  $output;
}
}