đź”§ New: User Management Graph PowerShell Toolkit

Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.

🚀 Launch Toolkit

How to Generate and Email Microsoft 365 Group Members Report?

Managing group memberships manually in Microsoft 365 can be tedious—especially when you need reports for compliance, audits, or regular administrative reviews. Instead of clicking through the UI for every group, let’s simplify the process using Graph PowerShell.

In this blog, you’ll learn how to generate and email a detailed group members report in just a few lines of code.


Who Are Microsoft 365 Group Members?

Microsoft 365 Groups (also known as Unified Groups) are collaborative entities that allow users to share resources like a shared inbox, calendar, SharePoint site, and more. Every group includes members, who are the users with access to the shared content.

Group members can include employees, guests, or service accounts depending on your setup.


Why Generate Microsoft 365 Group Members Report Using PowerShell?

For administrators, tracking who belongs to which group is critical. However, without automation, this means clicking through each group manually in the Microsoft 365 admin center—a time-consuming process, especially when you manage dozens or hundreds of groups.

This report helps you:

  • Ensure proper access control for resources tied to each group
  • Aid in audits and compliance checks by documenting group memberships
  • Save time by automating what would otherwise be a repetitive, error-prone process
  • Provide visibility to stakeholders (security, compliance, or team leads)

How to Generate & Email Microsoft 365 Group Members Report Using PowerShell?

Here’s a script that does everything—from connecting to Microsoft Graph, fetching group members, to emailing the report in a neat HTML table.

What This Script Does:

  • Connects to Microsoft Graph using required scopes
  • Fetches group info using Get-MgGroup
  • Fetches all members using Get-MgGroupMember
  • Builds a HTML table of member names and emails
  • Sends the report via email using Send-MgUserMail

    # Connect to Microsoft Graph
    Connect-MgGraph -Scopes "Group.Read.All", "User.Read.All", "Mail.Send"

    # Define the group and admin
    $groupId = "7ac400b1-72fe-47a4-b437-57671ca08f86"  # Replace with your group's ID
    $adminEmail = "samadmin@7xh7fj.onmicrosoft.com"   # Replace with the admin's email

    # Get group details
    $group = Get-MgGroup -GroupId $groupId
    $groupName = $group.DisplayName

    # Get group members
    $members = Get-MgGroupMember -GroupId $groupId -All

    # Build HTML table
    $htmlTable = "
        <html>
        <body>
        "
        $htmlTable += "<h3>Group Name: $groupName</h3>"
        $htmlTable += "<table border='1' cellpadding='5' cellspacing='0'>
        "
        $htmlTable += "
        <tr><th>Name</th><th>Email</th></tr>"

        foreach ($member in $members) {
            $name = $member.AdditionalProperties.displayName
            $email = $member.AdditionalProperties.mail
            $htmlTable += "
            <tr><td>$name</td><td>$email</td></tr>"
        }

        $htmlTable += "
        </table>
        </body>
        </html>"

    # Create email body
    $emailBody = @{
        Message = @{
        Subject = "Member List for Group: $groupName"
        Body = @{
            ContentType = "HTML"
            Content = $htmlTable
        }
        ToRecipients = @(
            @{
            EmailAddress = @{
            Address = $adminEmail
            }
        }
        )
        }
        SaveToSentItems = $true
    }

    # Send the email
    Send-MgUserMail -UserId $adminEmail -BodyParameter $emailBody

Possible Errors You Might Encounter

Here are some common issues you might face and how to fix them:

Error Cause Fix
Access Denied Missing Graph API permissions Ensure you’ve granted and consented to the required scopes (Group.Read.All, User.Read.All, Mail.Send)
MailboxNotEnabledForRESTAPI Mailbox not provisioned for sender/receiver Ensure both $adminEmail and $fromUser have valid mailboxes
Empty report Group ID is incorrect or group has no members Double-check the group ID and ensure the group contains members

Conclusion

Generating and emailing Microsoft 365 Group Members reports using Graph PowerShell can significantly reduce administrative overhead and enhance your visibility into group memberships. Whether you’re an IT admin or part of a compliance team, this report keeps your tenant’s group structure transparent and well-documented.


Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.

Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.

© Your Site Name. All Rights Reserved. Design by HTML Codex