Set-AzContext
設定 Cmdlet 要在目前工作階段中使用的租用戶、訂用帳戶和環境。
語法
Context (預設值)
Set-AzContext
[-Context] <PSAzureContext>
[-ExtendedProperty <System.Collections.Generic.IDictionary`2[System.String,System.String]>]
[-Name <String>]
[-Force]
[-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
TenantObject
Set-AzContext
[-TenantObject] <PSAzureTenant>
[-ExtendedProperty <System.Collections.Generic.IDictionary`2[System.String,System.String]>]
[-Name <String>]
[-Force]
[-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SubscriptionObject
Set-AzContext
[-SubscriptionObject] <PSAzureSubscription>
[-ExtendedProperty <System.Collections.Generic.IDictionary`2[System.String,System.String]>]
[-Name <String>]
[-Force]
[-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Subscription
Set-AzContext
[-Subscription] <String>
[-Tenant <String>]
[-ExtendedProperty <System.Collections.Generic.IDictionary`2[System.String,System.String]>]
[-Name <String>]
[-Force]
[-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
TenantNameOnly
Set-AzContext
-Tenant <String>
[-ExtendedProperty <System.Collections.Generic.IDictionary`2[System.String,System.String]>]
[-Name <String>]
[-Force]
[-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Set-AzContext Cmdlet 會設定您在目前工作階段中執行的 Cmdlet 的驗證資訊。
內容包括租用戶、訂用帳戶和環境資訊。
範例
範例 1:設定訂閱內容
Set-AzContext -Subscription "xxxx-xxxx-xxxx-xxxx"
Name Account SubscriptionName Environment TenantId
---- ------- ---------------- ----------- --------
Work test@outlook.com Subscription1 AzureCloud xxxxxxxx-x...
此命令會設定環境定義以使用指定的訂閱。
參數
-Confirm
在執行 Cmdlet 之前,提示您進行確認。
參數屬性
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Context
指定目前工作階段的內容。
參數屬性
參數集
Context
| Position: | 0 |
| 必要: | True |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-DefaultProfile
用於與 Azure 通訊的認證、租用戶和訂用帳戶。
參數屬性
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-ExtendedProperty
其他內容屬性
參數屬性
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Force
如果有的話,請以相同名稱覆寫現有的內容。
參數屬性
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Name
內容名稱
參數屬性
| 類型: | String
|
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Scope
決定環境定義變更的範圍,例如,變更是否僅套用至現行處理程序,或套用至此使用者啟動的所有階段作業。
參數屬性
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Subscription
應設定內容之訂用帳戶的名稱或識別碼。 此參數具有 -SubscriptionName 和 -SubscriptionId 的別名,因此,為了清楚起見,在指定 name 和 id 時,可以分別使用其中任何一個來代替 -Subscription。
參數屬性
| 類型: | String
|
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | SubscriptionId (訂閱識別碼), 訂閱名稱 |
參數集
Subscription
| Position: | 0 |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-SubscriptionObject
訂閱物件
參數屬性
參數集
SubscriptionObject
| Position: | 0 |
| 必要: | True |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Tenant
租用戶網域名稱或識別碼
參數屬性
| 類型: | String
|
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | 網域, 租戶識別碼 (TenantId) |
參數集
Subscription
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-TenantObject
租用戶物件
參數屬性
參數集
TenantObject
| Position: | 0 |
| 必要: | True |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-WhatIf
顯示 Cmdlet 執行時會發生什麼事。 指令未執行。
參數屬性
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
CommonParameters
此 cmdlet 支援常見參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters。
輸出