Azure Powershell Select-AzureSubscription with Subscription ID

I am using Powershell Azure cmdlets to perform some operations on each subscription.

However, all my subscriptions have the same name. So, if I perform an operation like:

$subs | ForEach-Object { Select-AzureSubscription -Current -SubscriptionName $_.SubscriptionName $services = Get-AzureService Write-Output "$($services .Length) services under $($_.SubscriptionId) subscription" } 

it always works for the same subscription, since subscriptions differ only in the subscription identifier.

And Select-AzureSubscription has no -SubscriptionId parameter.

Any ideas how I can find a workaround?

+6
source share
3 answers

Edit the publication settings file, giving each subscription a different name. Then re-import. At this point, you can easily access each of them by name.

+1
source

Not sure if this was added later, but as of November 2015 you can use -SubscriptionId

 Write-Host "Selecting Azure subscription using id" Select-AzureSubscription -SubscriptionId $subscriptionId 
+8
source

If you are an account administrator for your account, you can change the name of your subscription. Thus, when you or someone else who has access to the subscription download the publication settings, the name will be set the way you want.

http://rickrainey.com/windows-azure-how-tos/how-to-change-the-name-of-your-windows-azure-subscription/

+4
source

All Articles