Get-AzAccessToken
获取安全访问令牌。 使用 -ResourceUrl 时,请确保该值与当前的 Azure 环境匹配。 可以引用 (Get-AzContext).Environment
的值。
注释
出于安全考虑,默认输出类型已从纯文本 String
更改为 SecureString
。 有关详细信息,请参阅保护 Azure PowerShell 中的机密。
语法
Get-AzAccessToken
[-ResourceTypeName <String>]
[-TenantId <String>]
[-AsSecureString]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzAccessToken
-ResourceUrl <String>
[-TenantId <String>]
[-AsSecureString]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
说明
获取安全访问令牌
示例
示例 1 获取 ARM 终结点的访问令牌
Get-AzAccessToken -AsSecureString
获取 ResourceManager 终结点的当前帐户的访问令牌
示例 2 获取 Microsoft Graph 终结点的访问令牌
Get-AzAccessToken -AsSecureString -ResourceTypeName MSGraph
获取当前帐户的 Microsoft Graph 终结点的访问令牌
示例 3 获取 Microsoft Graph 终结点的访问令牌
Get-AzAccessToken -AsSecureString -ResourceUrl "https://graph.microsoft.com/"
获取当前帐户的 Microsoft Graph 终结点的访问令牌
参数
-AsSecureString
参数不再使用,但为了向后兼容而保留。 无论 AsSecureString
指定什么,输出令牌都是一个 SecureString
。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-DefaultProfile
用于与 Azure 通信的凭据、帐户、租户和订阅。
类型: | IAzureContextContainer |
别名: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ResourceTypeName
可选资源类型名称,支持的值:AadGraph、AnalysisServices、AppConfiguration、Arm、证明、Batch、CommunicationEmail、DataLake、KeyVault、MSGraph、OperationalInsights、ResourceManager、Storage、Synapse。 默认值为 Arm(如果未指定)。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ResourceUrl
请求令牌的资源 URL,例如“https://graph.microsoft.com/”。
类型: | String |
别名: | Resource, ResourceUri |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-TenantId
可选租户 ID。如果未指定,请使用默认上下文的租户 ID。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
输入
None