Share:
Twitter
LinkedIn
Facebook
Google+
Reddit
Whatsapp
Follow by Email

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

Login-AzureRmAccount
$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.

Share:
Twitter
LinkedIn
Facebook
Google+
Reddit
Whatsapp
Follow by Email
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