Answered by:
Powershell - Find all Azure Subscriptions associated with an Azure Active Directory Tenant

Question
-
Hi,
I have several Azure Active Directories to which I have access and am an administrator.
Some of them might be associated with more than one Azure Subscription, and some of those subscriptions may be already disabled.
I wanted to find out a simple powershell script that would show all Azure Subscriptions associated to each Azure Active Directory Tenant, and their state (active, disabled...).
Can anyone help?
Thank you.
Tuesday, June 28, 2016 5:32 PM
Answers
-
If you login to Azure PowerShell using the Azure Resource Manager I think you should be able to get what you want.
Login-AzureRMAccount Get-AzureRmSubscription | Group-Object State, TenantId
Regards,
James.
Senior Escalation Engineer EEE-Dev | Azure AD Serviceability | Azure AD Identity and Access Management | blog: http://www.edutech.me.uk
- Proposed as answer by James Evans - MSFT Sunday, July 3, 2016 5:59 AM
- Marked as answer by Zigoze Monday, July 4, 2016 9:04 AM
Sunday, July 3, 2016 5:59 AM
All replies
-
Get-MsolAccountSku has a -TenantId paramater.
eg
$Tenant1 = "6251f6c0-9427-432e-a705-8604332073bd" $Tenant2 = "915abd05-4f88-4935-8b64-ca1fe913f263" $Tenant3 = "974e98b6-0a6c-47e2-b3cd-09927e71c0bd" Get-MsolAccountSku -TenantId $Tenant1 Get-MsolAccountSku -TenantId $Tenant2 Get-MsolAccountSku -TenantId $Tenant3
or use a foreach loop or other approach, depending on what you want the output to look like.
Mike Crowley | MVP
My Blog -- Baseline TechnologiesWednesday, June 29, 2016 3:24 AM -
Hi Mike,
Thank you for your answer, but the commands you gave implicate to use the Connect-MsolService to connect to a O365 subscription.
All these tenants that I have access to are only Azure Subscriptions, no O365... so when I try to run the command Get-MsolAccountSku it gives an error indicating I have to run the Connect-MsolService first. But if I try to run it, I get an exception I think related to the fact of the user (Microsoft Account) that I use is Administrator, Owner or Co-Administrator of all subscriptions but has no access to any O365 subscriptions (nor does any exist for these tenants I administer...).
Any other suggestion?
Thank you
Wednesday, June 29, 2016 8:59 AM -
with your Microsoft account, you should be able to add an admin to each Azure AD subscription (AAD Account). You can use those creds to connect-msolservice.
pardon me if i'm still being dense
Mike Crowley | MVP
My Blog -- Baseline TechnologiesWednesday, June 29, 2016 7:28 PM -
If you login to Azure PowerShell using the Azure Resource Manager I think you should be able to get what you want.
Login-AzureRMAccount Get-AzureRmSubscription | Group-Object State, TenantId
Regards,
James.
Senior Escalation Engineer EEE-Dev | Azure AD Serviceability | Azure AD Identity and Access Management | blog: http://www.edutech.me.uk
- Proposed as answer by James Evans - MSFT Sunday, July 3, 2016 5:59 AM
- Marked as answer by Zigoze Monday, July 4, 2016 9:04 AM
Sunday, July 3, 2016 5:59 AM -
Mike, thank you for your suggestions.
James, you suggestion works great and simple!
Thank you all for your help.
Regards,
Miguel
Monday, July 4, 2016 9:05 AM