Today’s post is a very simple one. For those of you that like me, have multiple subscriptions on your Azure account and automate a lot of your Azure work via PowerShell, you might need to change between subscriptions, in the same PowerShell session, to execute multiple tasks.
This can be done with one of the two following cmdlets:
And here is where the confusion comes. What’s the difference between the two cmdlets and which one should you use?
Well the answer is the cmdlets do the exact same thing, and you should use the “Set-AzureRMContext” cmdlet, specially if you put it into scripts, since it seems to be the replacement for the “Select-AzureRMSubscription” cmdlet.
In fact, this is what you get when you do a “Get-Help Select-AzureRMContext”:
As you can see above all references point to the new cmdlet.
Now a quick note on how the cmdlet works.
To list all of your subscriptions:
To change the context to a different subscription:
Set-AzureRMContext -subscription <SubscriptionID or SubscriptionName>
I hope the above is helpful. Happy scripting!