Improved Select-AzureRmSubscription


Are you managing multiple subscriptions with a single corporate account?

I sometimes work with customers that uses multiple subscriptions in Azure, but uses the same Azure Active Directory, so you can atleast access them all from one account.

I searched the Internet and found this simple way of selecting the subscription from a list:

Adding it to a PS module, and here the selection is the module, but of course the module could be anything.

To finish it off, I would add Login-AzureRmAccount to the Beginning, but if you only have one account, I wouldn’t like to enter my credentials everytime I want to select a subscription:

What it does, is to try Get-AzureRmContext, but unless you are logged in, it will fail and based on that error message, it will make you run Login-AzureRmAccount. If your allready logged in with that PS Session, it will continue to present the subscription you have access in.

Thank you to everyone who shares their knowledge on the Internet.

Leave a Comment