共用方式為


Set-AzureSubscription

變更 Azure 訂用帳戶。

注意

本文件中參考的 Cmdlet 用於管理使用 Azure Service Manager(ASM) API 的舊版 Azure 資源。 建立新的資源時,不建議使用此舊版 PowerShell 模組,因為 ASM 已排定淘汰。 如需詳細資訊,請參閱 Azure Service Manager 淘汰

Az PowerShell 模組是使用 PowerShell 管理 Azure Resource Manager (ARM) 資源的建議 PowerShell 模組。

語法

Set-AzureSubscription
   -SubscriptionId <String>
   [-Certificate <X509Certificate2>]
   [-ServiceEndpoint <String>]
   [-ResourceManagerEndpoint <String>]
   [-CurrentStorageAccountName <String>]
   [-Context <AzureStorageContext>]
   [-Environment <String>]
   [-PassThru]
   [-Profile <AzureSMProfile>]
   [<CommonParameters>]
Set-AzureSubscription
   -SubscriptionName <String>
   [-Certificate <X509Certificate2>]
   [-ServiceEndpoint <String>]
   [-ResourceManagerEndpoint <String>]
   [-CurrentStorageAccountName <String>]
   [-Context <AzureStorageContext>]
   [-Environment <String>]
   [-PassThru]
   [-Profile <AzureSMProfile>]
   [<CommonParameters>]
Set-AzureSubscription
   -SubscriptionName <String>
   -SubscriptionId <String>
   -Certificate <X509Certificate2>
   [-ServiceEndpoint <String>]
   [-ResourceManagerEndpoint <String>]
   [-CurrentStorageAccountName <String>]
   [-Context <AzureStorageContext>]
   [-Environment <String>]
   [-PassThru]
   [-Profile <AzureSMProfile>]
   [<CommonParameters>]

Description

Set-AzureSubscription Cmdlet 會建立及變更 Azure 訂用帳戶對象的屬性。 您可以使用此 Cmdlet 在不是預設訂用帳戶或變更目前記憶體帳戶的 Azure 訂用帳戶中運作。 如需目前和預設訂用帳戶的相關信息,請參閱 Select-AzureSubscription Cmdlet。

此 Cmdlet 會在 Azure 訂用帳戶對象上運作,而不是實際的 Azure 訂用帳戶。 若要建立及布建 Azure 訂用帳戶,請流覽 Azure 入口網站https://azure.microsoft.com/)。

此 Cmdlet 會變更您在使用 Add-AzureAccountImport-AzurePublishSettingsFile Cmdlet 將 Azure 帳戶新增至 Windows PowerShell 時所建立的訂用帳戶數據文件中的數據。

本主題描述 Microsoft Azure PowerShell 模組 0.8.10 版本中的 Cmdlet。 若要取得您所使用的模組版本,請在 Azure PowerShell 控制台中輸入 (Get-Module -Name Azure).Version

範例

範例 1:變更現有的訂用帳戶1

C:\PS> $thumbprint = <Thumbprint-2>
C:\PS> $differentCert = Get-Item cert:\\CurrentUser\My\$thumbprint
C:\PS> Set-AzureSubscription -SubscriptionName ContosoEngineering -Certificate $differentCert

此範例會變更名為 ContosoEngineering 之訂用帳戶的憑證。

範例 2:變更服務端點

C:\PS> Set-AzureSubscription -SubscriptionName ContosoEngineering -ServiceEndpoint "https://management.core.contoso.com"

此命令會新增或變更 ContosoEngineering 訂用帳戶的自定義服務端點。

範例 3:清除屬性值

C:\PS> Set-AzureSubscription -SubscriptionName ContosoEngineering -Certificate $null -ResourceManagerEndpoint $Null

此命令會將 Certificate 和 ResourceManagerEndpoint 屬性的值設定為 null ($Null)。 這會清除這些屬性的值,而不會變更其他設定。

範例 4:使用替代訂用帳戶數據檔

C:\PS> Set-AzureSubscription -SubscriptionName ContosoFinance -SubscriptionDataFile C:\Azure\SubscriptionData.xml -CurrentStorageAccount ContosoStorage01

此命令會將 ContosoFinance 訂用帳戶的目前記憶體帳戶變更為 ContosoStorage01。 此命令會 使用 SubscriptionDataFile 參數來變更 C:\Azure\SubscriptionData.xml訂用帳戶數據檔中的數據。 根據預設, Set-AzureSubscription 會使用漫遊使用者配置檔中的預設訂用帳戶數據檔。

參數

-Certificate

類型:X509Certificate2
Position:Named
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-Context

類型:AzureStorageContext
Position:Named
預設值:None
必要:False
接受管線輸入:True
接受萬用字元:False

-CurrentStorageAccountName

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Environment

指定 Azure 環境。

Azure 環境是獨立部署Microsoft Azure,例如適用於全球 Azure 的 Azure 雲端,以及由中國 21Vianet 營運的 AzureChinaCloud。 您也可以使用 Azure Pack 和 WAPack Cmdlet 來建立內部部署 Azure 環境。 如需詳細資訊,請參閱 Azure Pack

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-PassThru

如果命令成功,並$False失敗,則傳回$True。 根據預設,此 Cmdlet 不會傳回任何輸出。

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Profile

指定此 Cmdlet 從中讀取的 Azure 設定檔。 如果您未指定設定檔,此 Cmdlet 會從本機預設配置檔讀取。

類型:AzureSMProfile
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-ResourceManagerEndpoint

指定 Azure Resource Manager 數據的端點,包括與帳戶相關聯的資源群組相關數據。 如需 Azure Resource Manager 的詳細資訊,請參閱 Azure Resource Manager Cmdlethttps://go.microsoft.com/fwlink/?LinkID=394765) 和使用 Windows PowerShell 搭配 Resource Managerhttps://go.microsoft.com/fwlink/?LinkID=394767)。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:True
接受萬用字元:False

-ServiceEndpoint

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:True
接受萬用字元:False

-SubscriptionId

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-SubscriptionName

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

輸入

None

您可以透過屬性名稱將輸入管線傳送至此 Cmdlet,但不能依值傳送。

輸出

None or System.Boolean

當您使用 PassThru 參數時,這個 Cmdlet 會傳回布爾值。 根據預設,此 Cmdlet 不會傳回任何輸出。