Private/Get-RyverUserFromID.ps1

function Get-RyverUserFromID {
    <#
    .SYNOPSIS
        Retrieves the Ryver user object from the map table.
 
    .DESCRIPTION
        Retrieves the Ryver user object from the map table.
 
    .INPUTS
        System.String[]
 
    .INPUTS
        System.String
 
    .NOTES
        - Troy Lindsay
        - Twitter: @troylindsay42
        - GitHub: tlindsay42
 
    .EXAMPLE
 
    .LINK
        https://tlindsay42.github.io/PSRyver/Private/Get-RyverUserFromID/
 
    .LINK
        https://github.com/tlindsay42/PSRyver/blob/master/PSRyver/Private/Get-RyverUserFromID.ps1
 
    .FUNCTIONALITY
        PowerShell Language
    #>

    [CmdletBinding(
        HelpUri = 'https://tlindsay42.github.io/PSRyver/Private/Get-RyverUserFromID/'
    )]
    [OutputType( [String] )]
    param (
        [Parameter(
            Mandatory = $true,
            Position = 0,
            ValueFromPipeline = $true
        )]
        [String[]]
        $ID,

        [Parameter( Position = 1 )]
        [Hashtable]
        $UserMap = $Script:PSRyverUserMap
    )

    begin {
        $function = $MyInvocation.MyCommand.Name

        Write-Verbose -Message (
            "Beginning: '${function}' with ParameterSetName '$( $PSCmdlet.ParameterSetName )' and Parameters: " +
            ( $PSBoundParameters | Remove-SensitiveData | Format-Table -AutoSize | Out-String )
        )

        if ( $UserMap.Keys.Count -like 0 ) {
            Write-Verbose -Message "No Ryver user map found. Please run: 'Get-RyverUserMap -Update'."
        }

        $map = @{}

        foreach ( $key in $UserMap.Keys ) {
            $map.Add( $UserMap[$key], $key )
        }
    }

    process {
        if ( $map.Keys.Count ) {
            foreach ( $userID in $ID ) {
                if ( $map.ContainsKey( $userID ) ) {
                    $map[$userID]
                }
                else {
                    $userID
                }
            }
        }
        else {
            $ID
        }
    }

    end {
        Write-Verbose -Message "Ending: '${function}'."
    }
}