Functions/SSL/Convert-TLS.ps1

Function Convert-TLS
    {
    [cmdletbinding()]
    Param()

    DynamicParam
        {
        # Get TranslationTable from function
        $TranslationTable = Get-TLSTranslationTable

        # Instantiate Runtime Parameter Dictionary, Attach Runtime Parameters, and return
        $RuntimeParameterDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
        $RuntimeParameterDictionary.Add('TLS', (New-DynamicParameter -ParamName 'TLS' -ValueType string -Dataset @($TranslationTable.keys + $TranslationTable.Values) -Mandatory $True -ValueFromPipeLine $true))
        return $RuntimeParameterDictionary
        }

    Process
        {
        # Convert Runtime Parameter Dictionary into Available Constants
        foreach ($key in $RuntimeParameterDictionary.keys){New-Variable -Name $key -Value $RuntimeParameterDictionary.$key.value}

        # Get converted Response Value
        $Response = if ($TLS -in $TranslationTable.Keys) {$TranslationTable.$TLS}
        elseif ($TLS -in $TranslationTable.Values) {($TranslationTable.GetEnumerator() | where value -eq $TLS).key}
        }
    End
        {
        # Output converted Response Value
        $Response
        }
    }