Get-AzAccessToken
取得安全的原始存取令牌。 使用 -ResourceUrl 時,請確定此值與目前的 Azure 環境相符。 您可以參考 (Get-AzContext).Environment
的值。
注意: 目前的默認輸出令牌類型將從純文本
String
變更為安全性SecureString
。 在重大變更生效之前,請使用-AsSecureString
移轉至安全行為。
語法
Get-AzAccessToken
[-ResourceTypeName <String>]
[-TenantId <String>]
[-AsSecureString]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzAccessToken
-ResourceUrl <String>
[-TenantId <String>]
[-AsSecureString]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
取得存取令牌
範例
範例 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
將輸出令牌轉換成安全字串的規格。
請一律將 參數用於安全性目的,並避免即將發生中斷的常數,並參閱 有關 Azure PowerShell 的常見問題,以瞭解如何從 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
選擇性租使用者識別碼。如果未指定,請使用預設內容的租用戶標識碼。
類型: | String |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
輸入
None
輸出
輸出類型即將淘汰。
使用 -AsSecureString
取得令牌作為 SecureString
。