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.
0 Comments