1
votes

I am trying to fetch all the members (co-administrators) of an Azure Subscription and their email IDs. I am a Global Administrator in this subscription so access is not an issue. I am looking for any PowerShell cmdlet or any API which can provide this information.

I have tried to run the following but it only gives me my information but no other accounts which are also co-administrators in my subscription.

Get-AzureSubscription -Id "22222aaa-2a22-2a22-a2aa-2a0525c574c3" | Select-Object Accounts

Any pointers or references will be really helpful.

2

2 Answers

1
votes

After a rather pertinent pointer from @BenV the actual answer is quite simple.

With the subscription you are interested in as the current subscription, you can use

Get-AzureRmRoleAssignment -IncludeClassicAdministrators

This will give you a list like this -

RoleAssignmentId   : 
Scope              : /subscriptions/{subscriptionid}
DisplayName        : {emailaddress}
SignInName         : {emailaddress}
RoleDefinitionName : ServiceAdministrator;AccountAdministrator
RoleDefinitionId   : 
ObjectId           : 00000000-0000-0000-0000-000000000000
ObjectType         : User
RoleAssignmentId   : 
Scope              : /subscriptions/{subscriptionid}
DisplayName        : {emailaddress}
SignInName         : {emailaddress}
RoleDefinitionName : CoAdministrator
RoleDefinitionId   : 
ObjectId           : 00000000-0000-0000-0000-000000000000
ObjectType         : User

Which should be what you're looking for

0
votes

I received the answer on msdn forums for this. I needed to use Azure AD PowerShell Modules and then connect using one Azure AD User. Microsoft Account user will not work. The exact cmdlet to fetch the users is "Get-MsolUser".

Please refer: https://social.msdn.microsoft.com/Forums/azure/en-US/29dfb413-e15e-4078-a292-394902667ed2/programmatically-fetching-all-members-of-an-azure-subscription?forum=WindowsAzureAD&prof=required