To get a list of all users that belong to a given role, the Microsoft Azure Active Directory module has a cmdlet Get-MsolRoleMember, however to run the cmdlet you must use the RoleObjectId parameter and provide a value. The possible values for RoleObjectId can be retrieved by running the Get-MsolRole cmdlet.
To simplify this, I wrote the Get-MsolRoleMemberDetails cmdlet. As you can see from the below screenshot, the list of available roles is dynamically populated.
For this cmdlet I am using Dynamic Parameters as explained in great detail here by Ed Wilson, the Microsoft Scripting Guy.
Hi,
I noticed you are using the older MSOnline PowerShell module in your examples. It may be useful to start using the newer Azure Active Directory PowerShell V2 module instead, as we will begin deprecating the MSOnline module when we have migrated the functionality of the MSOnline module to the newer module – currently planned for the Spring of 2017.
Thanks,
Rob de Jong