Remove-AzureAccount

從 Windows PowerShell 刪除 Azure 帳戶。

注意

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

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

語法

Remove-AzureAccount
      -Name <String>
      [-Force]
      [-PassThru]
      [-Profile <AzureSMProfile>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

Remove-AzureAccount Cmdlet 會從漫遊使用者配置檔中的訂用帳戶數據檔中刪除 Azure 帳戶及其訂用帳戶。 它不會從 azure Microsoft 中刪除帳戶,或以任何方式變更實際帳戶。

使用此 Cmdlet 非常類似於註銷您的 Azure 帳戶。 而且,如果您想要再次登入帳戶,請使用 Add-AzureAccountImport-AzurePublishSettingsFile 再次將帳戶新增至 Windows PowerShell。

您也可以使用 Remove-AzureAccount Cmdlet 來變更 Azure PowerShell Cmdlet 登入 Azure 帳戶的方式。 如果您的帳戶同時具有 Import-AzurePublishSettingsFile 的管理憑證和 Add-AzureAccount 的存取令牌,Azure PowerShell Cmdlet 只會使用存取令牌;它們會忽略管理憑證。 若要使用管理憑證,請執行 Remove-AzureAccount。 當 Remove-AzureAccount 同時找到管理憑證和存取令牌時,只會刪除存取令牌,而不是刪除帳戶。 管理憑證仍然存在,因此帳戶仍可供 Windows PowerShell 使用。

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

範例

範例 1:移除帳戶

PS C:\> Remove-AzureAccount -Name admin@contoso.com

這個指令會 admin@contoso.com 從您的訂用帳戶資料檔案中移除 。 當命令完成時,Windows PowerShell 就無法再使用帳戶。

參數

-Confirm

執行 Cmdlet 之前先提示您確認。

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

-Force

隱藏確認提示。 根據預設, Remove-AzureAccount 會在從 Windows PowerShell 移除帳戶之前提示您。

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

-Name

指定要移除的帳戶名稱。 參數值會區分大小寫。 不支援萬用字元。

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

-PassThru

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

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

-Profile

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

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

-WhatIf

顯示執行 Cmdlet 後會發生的情況。 未執行 Cmdlet。

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

輸入

None

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

輸出

None or System.Boolean

如果您使用 PassThru 參數,此 Cmdlet 會傳回布爾值。 否則,它不會傳回任何輸出。