How to connect Azure Account with multiple subscriptions via Powershell

969 views Asked by At

I am trying to get list of all storage account present in my subscription along with their GeoReplication properties.

I am using Get-AzStorageAccount command but I'm getting empty response even storage accounts are there.

I came to know that I connected to a subscription where there are no storage accounts. I don't know how to shift into another subscription of same Azure account via PowerShell.

I found that I can use Set-Context command but no idea how to use that.

Can anyone give me some idea about how to connect to different subscription and get that list of storage accounts???

1

There are 1 answers

0
Nick H. On BEST ANSWER

We wrestle with this a lot too. You need to set your context like so:

$subscriptionId = '1a1e0e55-74fb-4231-a84a-30b7900e656a';  # replacing this GUID with your subscription GUID

Get-AzSubscription -SubscriptionId $subscriptionId | Set-AzContext;