Public/Connect-Pegasus.ps1
|
<# .SYNOPSIS Connects to the Inbound Provisioning API using the specified credentials. The credentials are stored in the script scope and used for all subsequent calls to the API. .EXAMPLE $Credential = Get-Credential Connect-Pegasus -ClientSecretCredential $Credential -TenantId "00000000-0000-0000-0000-000000000000" #> function Connect-Pegasus { [CmdletBinding(DefaultParameterSetName = "fqdn")] Param ( [Parameter(Mandatory = $true, ParameterSetName = "fqdn")] [String] $FQDN, [Parameter(Mandatory = $true, ParameterSetName = "apiroot")] [String] $APIRoot, [Parameter(Mandatory = $false)] [String] $EntraIDAccessTokenProfile = "Pegasus" ) Process { if($PSCmdlet.ParameterSetName -eq "apiroot") { $Script:APIRoot = $APIRoot } else { $Script:APIRoot = "https://{0}/" -f $FQDN.TrimEnd('/') } $Script:EntraIDAccessTokenProfile = $EntraIDAccessTokenProfile Get-EntraIDAccessToken -Profile $EntraIDAccessTokenProfile | Out-Null } } |