powershell script to export all the groups and group members from Azure AD

tally wizu 1 Reputation point


Please I need help with a powershell script that can export all the groups and group members of an azure ad and their attributes to a storage account, table storage

Get a list of all Groups in AD first (Get-AzADGroup)

Loop through all Groups and get Members of the group

Loop through all members and get the member info (userprincipal, userid, user, givenname, surname, usertype, accountenabled, etc.) (Get-AzADGroupMember)

Connect to Table Storage (Get-AzStorageAccount)
Get Table Storage Rows (Get-AzTableRow)
Add a Table Row to Table Storage (Add-AzTableRow) using a consistent row key

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,344 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,306 questions
{count} votes

2 answers

Sort by: Most helpful
  1. James Hamil 21,386 Reputation points Microsoft Employee

    Hi @tally wizu , have you looked into bulk downloading? https://learn.microsoft.com/en-us/azure/active-directory/enterprise-users/groups-bulk-download-members

    This may be faster than creating a PowerShell script. Please let me know if you have any questions!


    0 comments No comments

  2. Stars75238 1 Reputation point

    @James Hamil & @Anshul Kumar (MINDTREE LIMITED) ,

    I looked at the referenced article and it looks like it will get what I needed from a single group. I have over 900 groups that I need to get this information so is there an option to download all of the groups and members in the same process and not 1 at a time? The list I am needing also contains my onPrem groups so the one list is all I would need.

    Any assistance would be much appreciated and if there is a PS script that generates this that would be Great. I am not trained enough in PS to write an overly complex script.


    0 comments No comments