I am trying to find a way to check the AD roles attached to a user. After a lot of reading, it seems like there is no cli call that can provide this information. The workaround I am thinking is to list out all the users who have "Global Administrator" permission in the AD role. Is there an azure CLI call that can help with getting this information? I tried the calls in az ad user
but none of them have the information I am looking for.
2
Answers
Here is Powershell and Graph API example how you can do that.
I agree with @Panagiotis Kanavos, you can make use of HTTP requests by calling them from Azure CLI.
You can use below MS Graph query to get the list the users with Global Administrator role:
To call the above query from Azure CLI, you can use
az rest
command like below:I tried to reproduce the same in my environment and got below results:
I have below users in my tenant, assigned with Global Administrator role:
To get these results from Azure CLI, I ran below command:
Response: