Functions/Data/Switch-Hashtable.ps1

Function Switch-Hashtable
    {
    [cmdletbinding()]
    Param
        (
        # Hashtable
        [Parameter(Mandatory=$true,valuefrompipeline=$true)]
        [hashtable]
        $Hashtable,

        # Order Status
        [Parameter(Mandatory=$false)]
        [boolean]
        $Ordered = $true
        )
    End
        {
        # Instantiate New Hashtable
        $NewHash = switch ($Ordered)
            {
            $true {[ordered]@{}}
            $false {@{}}
            }
        # Invert Existing Hashtable Keys into New Hashtable
        Foreach ($Key in ([array]$HashTable.keys)){$NewHash.Add("$($Hashtable.$Key)",$Key)}
        
        # Output new Hashtable
        $NewHash
        }
    }