Auth.ps1


#
# Authentication to Citrix Cloud
#

Function AuthToCitrixCloud([string]$customerId, [string]$secureClientId, [string]$secureSecret) {
    $parameters = @{
        CustomerId = $customerId
        Verbose = $Global:LogVerbose
    }
    if ([string]::IsNullOrWhiteSpace($secureClientId) -Or [string]::IsNullOrWhiteSpace($secureSecret)) {
        LogIt "Interactively authenticating for Citrix customer $customerId."
    }
    else {
        LogIt "Authenticating for Citrix customer $customerId using API key $secureClientId."
        Set-XDCredentials -CustomerId $customerId -APIKey $secureClientId -SecretKey $secureSecret -ProfileType CloudAPI
    }
    try {
        Get-XDAuthentication @parameters
    }
    catch {
        LogIt "Unable to authenticate to Citrix Cloud: $_"
        throw
    }
    LogIt "Authenticated for Citrix customer $customerId."
    return $parameters
}