Get-​Azure​Stack​Token

Gets a token that is used to make calls to the Azure stack resource manager.

Syntax

Get-AzureStackToken
   [-Authority] <String>
   -AadTenantId <String>
   [-ClientId <String>]
   [-Credential <PSCredential>]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [-PipelineVariable <String>]
   -Resource <String>
   [<CommonParameters>]
Get-AzureStackToken
   [-Authority] <String>
   [-ClientId <String>]
   [-Credential <PSCredential>]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [-PipelineVariable <String>]
   [-Resource <String>]
   [<CommonParameters>]

Description

The Get-AzureStackToken cmdlet gets a token that is used to make calls to the Azure stack resource manager.

Examples

Example 1: Get an access token for a specified user

$Endpoints = Invoke-RestMethod -Method Get -Uri "$($ArmEndpoint.TrimEnd('/'))/metadata/endpoints?api-version=2015-01-01" -Verbose
$AAdAuthorityEndpoint = $Endpoints.authentication.loginEndpoint
$AAdResource = $Endpoints.authentication.audiences\[0\]

Get-AzureStackToken -Authority $AAdAuthorityEndpoint -AadTenantId $AadTenantId -Resource $AAdResource -Credential (Get-Credential) -Verbose

The first command gets the login endpoints and stores the result in the variable named $Endpoints. The second command gets the authentication information and stores the result in the variable named $AAdAuthorityEndpoint. The third command gets the users from the $Endpoints variable and stores the result in the variable named $AAdResource. The forth command gets the access token for the specified user.

Required Parameters

-AadTenantId

Specifies the Azure active directory (AAD) tenant ID of the user belonging to the AAD tenant group.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Authority

Specifies the endpoint for authentication, typically of the form "https://login.windows.net". To obtain this value, access the Azure resource manager (ARM) metadata endpoint https://<ArmUri>/metadata/endpoints?api-version=2015-01-01 and read the value of loginEndpoint.

Type:String
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Optional Parameters

-ClientId

Specifies the client ID for the Azure Stack token.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Credential

Specifies the credential for the user for whom we need the access token.

Type:PSCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InformationAction

Specifies how this cmdlet responds to an information event.

Type:ActionPreference
Aliases:infa
Parameter Sets:SilentlyContinue, Stop, Continue, Inquire
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InformationVariable

Specifies a variable that is used for storing an informational message.

Type:String
Aliases:iv
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-PipelineVariable

Specifies a variable that stores the value of the current pipeline element.

Type:String
Aliases:pv
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Resource

Specifies the resource for authentication. To obtain this value, access the Azure resource manager (ARM) metadata endpoint https://<ArmUri>/metadata/endpoints?api-version=2015-01-01 and read the value of audiences.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

None

Outputs

System.Object