Get-AzAccessToken
Get secure raw access token. When using -ResourceUrl, please make sure the value does match current Azure environment. You may refer to the value of (Get-AzContext).Environment
.
NOTE: The current default output token type is going to be changed from plain text
String
toSecureString
for security. Please use-AsSecureString
to migrate to the secure behaviour before the breaking change takes effects.
Get-AzAccessToken
[-ResourceTypeName <String>]
[-TenantId <String>]
[-AsSecureString]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzAccessToken
-ResourceUrl <String>
[-TenantId <String>]
[-AsSecureString]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get access token
Get-AzAccessToken -AsSecureString
Get access token of current account for ResourceManager endpoint
Get-AzAccessToken -AsSecureString -ResourceTypeName MSGraph
Get access token of Microsoft Graph endpoint for current account
Get-AzAccessToken -AsSecureString -ResourceUrl "https://graph.microsoft.com/"
Get access token of Microsoft Graph endpoint for current account
Specifiy to convert output token as a secure string.
Please always use the parameter for security purpose and to avoid the upcoming breaking chang and refer to Frequently asked questions about Azure PowerShell for how to convert from SecureString
to plain text.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
The credentials, account, tenant, and subscription used for communication with Azure.
Type: | IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Optional resource type name, supported values: AadGraph, AnalysisServices, AppConfiguration, Arm, Attestation, Batch, CommunicationEmail, DataLake, KeyVault, MSGraph, OperationalInsights, ResourceManager, Storage, Synapse. Default value is Arm if not specified.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Resource url for that you're requesting token, e.g. 'https://graph.microsoft.com/'.
Type: | String |
Aliases: | Resource, ResourceUri |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Optional Tenant Id. Use tenant id of default context if not specified.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
None
The output type is going to be deprecate.
Use -AsSecureString
to get the token as SecureString
.
Azure PowerShell feedback
Azure PowerShell is an open source project. Select a link to provide feedback: