Tuesday, November 3, 2015

How to Remove Azure Account (Cached) using PowerShell

Recently I’ve done quite a lot of testing using various accounts to Azure.  All the commands are executed in the PowerShell ISE (Run ISE are Administrator).

The PowerShell should have the Azure Commands in it already.  If not, can download from here.

Select the Install from the Command-line tools

image

When I tried to Get-AzureAccount, it displayed more than one account and subscriptions

image

I need to remove the other subscriptions.  Therefore I perform as follow :

image

Execute the command as below :

  • Get-AzureAccount | format-table id

Once displayed, I execute to remove the account using

  • Remove-AzureAccount account-name

Note : Just replace the account-name with the account that needs to be deleted.

Another way is to remove all the accounts then re-add it back. 

To do this execute it as below to remove all the accounts :

  • Get-AzureAccount | ForEach-Object {Remove-AzureAccount $_.ID -Force}

To add the account that I’m working on, use :

  • Add-AzureAccount

 

keys : add azure account, remove azure account in cache, Azure powershell command line, command-line, azure subscription, AzureSubscription, get-azureaccount, remove-azureaccount