I need to export the list of user in Azure with their respective permissions on resources Groups and resources and need to export to excel files via powershell command.

Anji Babu Eluri 1 Reputation point
2021-12-09T07:00:50.697+00:00

Hi Team,
I need to export the list of user in Azure with their respective permissions on resources Groups and resources and need to export to excel files via PowerShell command.
Please find the attachment of excel file for the formate.

Note: In my prod Env we have more than 250 Resource groups there. We would like to validate the users access on the Resource groups.

Regards
Anjibabu156120-sample-azure-report.png

Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. James Hamil 27,211 Reputation points Microsoft Employee Moderator
    2021-12-10T00:50:21.217+00:00

    Hi @Anji Babu Eluri , would this document work for you? You can filter users and download them to a .csv. It's not exactly what you asked for but it may be an option to consider. If not please let me know and I can help you further.

    If this answer helped you please mark it as "Verified" so other users may reference it.

    Thank you,
    James


  2. Manu Philip 20,206 Reputation points MVP Volunteer Moderator
    2021-12-10T14:56:07.02+00:00

    I have prepared an az scripts as below:
    Save the script as a ps1 file and run it in your az PS window.
    Note that, your subscription should be connected already before running the script

    Get-AzResourceGroup| foreach-object { $ResourceGroupName = $_.ResourceGroupName Get-AzRoleAssignment | Select-Object DisplayName,RoleAssignmentID,@{Name = "ResourceGroup Name"; Expression = { (Get-AzResourceGroup $ResourceGroupName).ResourceGroupName}} ,Scope,RoleDefinitionName,@{name="SubscriptionName";expression = {$Name}},ObjectType | Sort-Object DisplayName }-OutVariable azusers $azusers | Export-CSV UserList.csv -NoTypeInformation -Encoding UTF8


  3. Manu Philip 20,206 Reputation points MVP Volunteer Moderator
    2021-12-13T12:59:18.033+00:00

    I am providing more details to run the script as below:

    1. Copy the script to a text file Get-AzResourceGroup| foreach-object { $ResourceGroupName = $_.ResourceGroupName Get-AzRoleAssignment | Select-Object DisplayName,RoleAssignmentID,@{Name = "ResourceGroup Name"; Expression = { (Get-AzResourceGroup $ResourceGroupName).ResourceGroupName}} ,Scope,RoleDefinitionName,@{name="SubscriptionName";expression = {$Name}},ObjectType | Sort-Object DisplayName }-OutVariable azusers $azusers | Export-CSV UserList.csv -NoTypeInformation -Encoding UTF8
    2. Save as a ps1 file under any folder (example C:\script\azuser.ps1
    3. Connect Azure account in PowerShell (az login)
    4. Run the script (example PS C:\script> .\azuser.ps1
    5. If it works well, the result will be saved in the same folder with name UserList.csv

    Let me know if you are able to run it well


  4. Sajid 1 Reputation point
    2022-08-31T14:44:56.513+00:00

    Hi Manu,

    Hope you doing well !

    i am looking for a script where i can fetch the user IAM both subscription level and resource group level.
    can you pls help on this .

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.