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

tally wizu 1 Reputation point
2021-07-12T20:24:08.303+00:00

2

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,576 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,413 questions
{count} votes

2 answers

Sort by: Most helpful
  1. James Hamil 26,026 Reputation points Microsoft Employee
    2021-07-16T22:40:10.863+00:00

    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!

    Best,
    James

    0 comments No comments

  2. Stars75238 1 Reputation point
    2022-10-06T20:16:23.98+00:00

    @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.

    Michael

    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.