The more I work on Azure, the more I am having to switch between subscriptions. Now, this usually means copying and pasting the subscription ID every time. This is no good! So I decided to see if I can script a subscription selector and I did. It’s below!

The script basically gets you to login to your Azure subscription, then uses Get-AzureRmSubscription to output the subscriptions into an Out-GridView. You then select the subscription you would like to use and then click OK.

I have started to add this script to my bigger Azure scripts. No more Azure resources in the wrong subscription for me!

The Script

$SubscriptionId = (Get-AzureRmSubscription | select Name, State, SubscriptionId, TenantId | Out-GridView -Title "Azure Subscription Selector" -PassThru).SubscriptionId
Get-AzureRmSubscription -SubscriptionId $SubscriptionId | Select-AzureRmSubscription

I hope you found this article helpful. If you have any questions or comments please reach out.

Categories: AzurePowerShell

Pixel Robots.

I’m Richard Hooper aka Pixel Robots. I started this blog in 2016 for a couple reasons. The first reason was basically just a place for me to store my step by step guides, troubleshooting guides and just plain ideas about being a sysadmin. The second reason was to share what I have learned and found out with other people like me. Hopefully, you can find something useful on the site.

Leave a Reply

Your email address will not be published. Required fields are marked *


I agree

This website stores some user agent data. These data are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to opt-out of any future tracking, a cookie will be set up in your browser to remember this choice for one year. I Agree, Deny