Get-AzContext
Azure Resource Manager 要求の認証に使用されるメタデータを取得します。
構文
GetSingleContext (既定)
Get-AzContext
[[-Name] <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
ListAllContexts
Get-AzContext
[-ListAvailable]
[-RefreshContextFromTokenCache]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
説明
Get-AzContext コマンドレットは、Azure Resource Manager 要求の認証に使用される現在のメタデータを取得します。
このコマンドレットは、Active Directory アカウント、Active Directory テナント、Azure サブスクリプション、および対象となる Azure 環境を取得します。
Azure Resource Manager コマンドレットは、Azure Resource Manager 要求を行うときに既定でこれらの設定を使用します。 利用可能なサブスクリプションの量が既定の制限である 25 を超えると、一部のサブスクリプションが Get-AzContext -ListAvailable
の結果に表示されないことがあります。
Connect-AzAccount -MaxContextPopulation <int>
を実行して、より多くのコンテキストを取得してください。
例
例 1: 現在のコンテキストの取得
Connect-AzAccount
Get-AzContext
Name Account SubscriptionName Environment TenantId
---- ------- ---------------- ----------- --------
Subscription1 (xxxxxxxx-xxxx-xxxx-xxx... test@outlook.com Subscription1 AzureCloud xxxxxxxx-x...
この例では、Connect-AzAccount を使用して Azure サブスクリプションを使用してアカウントにログインし、Get-AzContext を呼び出して現在のセッションのコンテキストを取得します。
例 2: 使用可能なすべてのコンテキストを一覧表示する
Get-AzContext -ListAvailable
Name Account SubscriptionName Environment TenantId
---- ------- ---------------- ----------- --------
Subscription1 (xxxxxxxx-xxxx-xxxx-xxx... test@outlook.com Subscription1 AzureCloud xxxxxxxx-x...
Subscription2 (xxxxxxxx-xxxx-xxxx-xxx... test@outlook.com Subscription2 AzureCloud xxxxxxxx-x...
Subscription3 (xxxxxxxx-xxxx-xxxx-xxx... test@outlook.com Subscription3 AzureCloud xxxxxxxx-x...
この例では、現在使用可能なすべてのコンテキストが表示されます。 ユーザーは、Select-AzContext を使用してこれらのコンテキストのいずれかを選択できます。
パラメーター
-DefaultProfile
Azure との通信に使用される資格情報、アカウント、テナント、サブスクリプション
パラメーターのプロパティ
型: | IAzureContextContainer |
規定値: | None |
ワイルドカードのサポート: | False |
DontShow: | False |
Aliases: | AzContext, AzureRmContext, AzureCredential |
パラメーター セット
(All)
配置: | Named |
必須: | False |
パイプラインからの値: | False |
プロパティ名別のパイプラインからの値: | False |
残りの引数からの値: | False |
-ListAvailable
現在のセッションで使用可能なすべてのコンテキストを一覧表示します。
パラメーターのプロパティ
型: | SwitchParameter |
規定値: | None |
ワイルドカードのサポート: | False |
DontShow: | False |
パラメーター セット
ListAllContexts
配置: | Named |
必須: | True |
パイプラインからの値: | False |
プロパティ名別のパイプラインからの値: | False |
残りの引数からの値: | False |
-Name
コンテキストの名前
パラメーターのプロパティ
型: | String |
規定値: | None |
ワイルドカードのサポート: | False |
DontShow: | False |
パラメーター セット
GetSingleContext
配置: | 0 |
必須: | False |
パイプラインからの値: | False |
プロパティ名別のパイプラインからの値: | False |
残りの引数からの値: | False |
-RefreshContextFromTokenCache
トークン キャッシュからコンテキストを更新する
パラメーターのプロパティ
型: | SwitchParameter |
規定値: | None |
ワイルドカードのサポート: | False |
DontShow: | False |
パラメーター セット
ListAllContexts
配置: | Named |
必須: | False |
パイプラインからの値: | False |
プロパティ名別のパイプラインからの値: | False |
残りの引数からの値: | False |
CommonParameters
このコマンドレットでは、一般的なパラメーター -Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction、-WarningVariable の各パラメーターがサポートされています。 詳細については、about_CommonParametersを参照してください。