Is it possible to manually export dynamic group to include membership rules?

Pender Sessoms 30 Reputation points
2023-07-07T20:41:04.6566667+00:00

I have exhausted Google and I have a tenant with approximately 90 dynamically assigned groups that I need to export to a csv file that will show their membership rules. So far, I am unable to do so. Please can anyone shed some light before I individually go through each group (copy and paste) each membership rule for all 90 groups? Please and thank you.

-new cloud analyst (intern)

Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Entra | Other
{count} vote

2 answers

Sort by: Most helpful
  1. Vasil Michev 119.6K Reputation points MVP Volunteer Moderator
    2023-07-08T15:46:10.6966667+00:00

    Are those Azure AD groups, or Exchange dynamic DGs? Assuming the former, you can use the following:

    Get-MgGroup -Filter "groupTypes/any(x:x eq 'dynamicmembership')" | select Id,DisplayName, MembershipRule | Export-CSV -nti "blabla.csv"

    For Exchange Online DDGs, use the Get-DynamicDistributionGroup cmdlet instead:

    Get-DynamicDistributionGroup | select Name,RecipientFilter | Export-csv -NTI "blabla.csv"

    2 people found this answer helpful.

  2. Sandeep G-MSFT 20,906 Reputation points Microsoft Employee Moderator
    2023-07-10T06:53:05.32+00:00

    @Pender Sessoms

    Thank you for posting your question in Microsoft Q&A.

    I have tried this in my lab and I got the correct report for all dynamic groups with there membership rules.

    This cannot be performed via GUI.

    However, you can use PowerShell to get the output with all dynamic groups with there membership rules.

    Follow below steps,

    • Open Windows PowerShell as administrator.
    • Run command "Import-Module Microsoft.Graph.Groups"
    • Once you install the module you can run command Connect-MgGraph -Scopes "group.read.all". Enter the Global admin credentials if it prompts for credentials.
    • Run command "Get-MgGroup -All | Where-Object GroupTypes -EQ "DynamicMembership" | select -Property GroupTypes,DisplayName,MembershipRule | Export-Csv c:\testchecker.csv"

    NOTE: You can change the path at the end of the command for exporting the output.

    Above command will pull all Dynamic group types along with their displayname and MembershipRule.

    Output will be exported to csv.

    Let me know if you have any further questions on this.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    1 person found this answer helpful.
    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.