Offer Offer

News We Recently Launched AD Migrator and AD Reporter.

How to Export Office 365 Group Members to CSV – A Guide for IT Admin

  author
Written By Mohit Jha
Anuraag Singh
Approved By Anuraag Singh
Published On June 20th, 2024
Reading Time 8 Minutes Reading

Exporting Office 365 group members to CSV can greatly assist IT admins in better management in several ways. It can enhance administrative efficiency, support compliance efforts, and strengthen security measures. Not only this, it also enables proactive management of group memberships within an organization. But when it comes to exporting the user list, they often get confused about the right way. Hence, in this guide, we are describing the best ways to perform this task.

Table of Content

Microsoft 365 Groups are valuable collaboration services integrated by Microsoft in their most popular productivity suite i.e. Office 365. When it comes to team collaboration, It allows members to communicate effectively, share files, and collaborate while writing documents, creating spreadsheets, working on project plans, scheduling meetings, or sending emails. 

It allows you to add a set of users and a collection of respective resources from your organization that you need to collaborate with and share. These resources include a shared Outlook inbox, shared calendar, or a document library for collaborating on files. One of the most remarkable features of Microsoft 365 groups is that you do not need to assign permissions to each user to access the resources. When you add a user to the group it automatically assigns all the persimmons they need to the tools your group provides.

When it comes to managing Office 365 groups, requires a set of different tasks such as finding the list of resources that need to be shared among the users. Apart from this, the most important task is to have a complete list of added users in the respective groups. 

However, exporting Office 365 group members to CSV (Comma comma-separated values) format is not an easy task, it might require multiple permissions and at the user level, it might not be possible to export the list. Hence, In this guide, we’ll walk you through the step-by-step process of exporting Office 365 group members to CSV.

But before getting into the solution, learning more about the types of Microsoft 365 groups is important

Different Types of Microsoft 365 Group 

Microsoft offers mainly 5 different types of groups in the Mircosoft 365 suite. Let’s have a quick overview of all of them.

  1. Microsoft 365

It enables you to collaborate among team members by providing you with a group email address and a shared workspace. You can utilize the shared workplace for conversations, file sharing, and scheduling events in calendars. Microsoft 365 groups are called groups in Outlook.

  1. Distribution List or Groups

It enables you to broadcast notifications to a group of people in an organization by using an email address. Additionally, the administrators can also enable receiving external email. It works best when you need to send notifications to a set of people such as – [email protected]. You can not add Microsoft 365 groups as a member of the Distribution List.

  1. Dynamic Distribution List or Groups

It automatically sends emails to its members based on defined attributes like department or location. As the name suggests, the members of Dynamic Distribution groups get updated every 24 hours. Unlike regular groups, attributes are defined in the Exchange admin center rather than Microsoft Entra ID.

  1. Security groups

Security groups are used by administrators to grant specific access to the respective resources, for example, SharePoint sites. It makes the entire resource allocation a breeze task, as the admin does not need to assign resources individually, rather he just needs to administer the group

  1. Mail-enabled security

It is used by administrators to grant specific access to the respective resources with an email notification to all the members of the group. This includes resources such as ‎OneDrive‎, ‎SharePoint‎ , and admin roles.

Now let’s discuss the elephant in the room i.e. how to export Office 365 group members. to CSV in the coming section. 

Export Office 365 Group Members to CSV Using Admin Center

  • Step 1. Log in to the Office 365 Admin Center with your administrator credentials.
  • Step 2. Go to the “Groups” section.
  • Step 3. Choose the Office 365 group you want to export members from.
  • Step 4. Access the list of group members.
  • Step 5. Look for an export option, usually labeled “Export” or “Download.”
  • Step 6. Select the format for the export file, such as CSV or Excel.
  • Step 7. Save the exported file to your desired location.
  • Step 8. Open the exported file to review the Office 365 group members’ details

Export Office 365 Group Members to CSV Using PowerShell

Using PowerShell you can export members of any group, just follow the below-listed steps accordingly.  

Stage 1. Install Microsoft Graph PowerShell Module:

Step 1. Run Windows PowerShell as administrator.

Step 2. Execute the following commands:

     Install-Module Microsoft.Graph -Force      Install-Module Microsoft.Graph.Beta -AllowClobber -Force
Stage 2. Prepare Export Script:

Step 1. Create “Temp” and “Scripts” folders on the C: drive.

Step 2. Download the Export script to the “Scripts” folder or create a new script named “Export-M365GroupMembers.ps1” with the provided code.

#>

# CSV file path to export

$CsvPath = "C:\temp\SysToolsGroupMembers.csv"

# Connect to SysTools Graph with specified scopes

Connect-SysToolsGraph -Scopes "User.Read.All", "Group.Read.All"

# Retrieve all groups

$groups = Get-SysToolsGroup -All

# Get properties

$Properties = @(

    'Id', 'DisplayName', 'UserPrincipalName', 'UserType', 'AccountEnabled'

)

# Initialize an array to store user information

$allUsers = @()

# Set up the progress bar parameters

$totalGroups = $groups.Count

$currentGroup = 0

# Iterate through each group and retrieve group members

foreach ($group in $groups) {

    # Retrieve group members using the valid Group ID

    $members = Get-SysToolsGroupMember -GroupId $group.id -All


    # Determine the group type

    $groupType = if ($group.groupTypes -eq "Unified" -and $group.securityEnabled) { "SysTools 365 (security-enabled)" }

    elseif ($group.groupTypes -eq "Unified" -and !$group.securityEnabled) { "SysTools 365" }

    elseif (!($group.groupTypes -eq "Unified") -and $group.securityEnabled -and $group.mailEnabled) { "Mail-enabled security" }

    elseif (!($group.groupTypes -eq "Unified") -and $group.securityEnabled) { "Security" }

    elseif (!($group.groupTypes -eq "Unified") -and $group.mailEnabled) { "Distribution" }

    else { "N/A" }


    # If there are no members, create an object with empty values

    if ($members.Count -eq 0) {

        $Objects = [PSCustomObject][ordered]@{

            GroupId            = $group.Id

            GroupDisplayName   = $group.DisplayName

            GroupType          = $groupType

            UserDisplayName    = "N/A"

            UserPrincipalName  = "N/A"

            UserAlias          = "N/A"

            UserType           = "N/A"

            UserAccountEnabled = "N/A"

        }

        $allUsers += $Objects

    }

    else {

        # Iterate through each group member and retrieve user details

        foreach ($member in $members) {

            $user = Get-SysToolsUser -UserId $member.Id -Property $Properties -ErrorAction SilentlyContinue | Select-Object $Properties


            # Check if $user is not null before accessing properties

            if ($user.Count -ne 0) {

                # Extract the alias from the UserPrincipalName

                $alias = $user.UserPrincipalName.Split("@")[0]




                # Create an ordered custom object with properties in a specific order

                $Objects = [PSCustomObject][ordered]@{

                    GroupId            = $group.Id

                    GroupDisplayName   = $group.DisplayName

                    GroupType          = $groupType

                    UserDisplayName    = $user.DisplayName

                    UserPrincipalName  = $user.UserPrincipalName

                    UserAlias          = $alias

                    UserType           = $user.UserType

                    UserAccountEnabled = $user.AccountEnabled

                }


                # Add the ordered custom object to the array

                $allUsers += $Objects

            }

        }

    }


    # Update the progress bar

    $currentGroup++

    $status = "{0:N0}" -f ($currentGroup / $totalGroups * 100)


    $progressParams = @{

        Activity        = "Retrieving Group Members"

        Status          = "Processing group: $($group.DisplayName) - $currentGroup of $totalGroups : $status% completed"

        PercentComplete = ($currentGroup / $totalGroups) * 100

    }

    Write-Progress @progressParams

}


# Complete the progress bar

Write-Progress -Activity "Retrieving Group Members" -Completed


# Export all user information to a CSV file

$allUsers | Sort-Object GroupDisplayName | Export-Csv $CsvPath -NoTypeInformation -Encoding utf8
  • Ensure the script is unblocked.
  • Modify line 21 with the desired CSV path.

Step 3. Run Export Script: Execute the script using the command

     c:\scripts\.\Export-M365GroupMembers.ps1

Step 4. Now you can open the report. Locate the generated CSV file “M365GroupMembers.csv” in the C:\temp directory. Open the CSV file with Excel or any preferred application to view the Microsoft 365 group members report.

What If You Want to Export the Mailbox Data Too?

Once you have successfully exported the Office 365 group members to a CSV file, there might be situations where you need to export Office 365 mailbox data locally. In this case, you utilize our most prominent Office 365 export tool

Free Download Purchase Now

Some of its features are as follows:

  • It allows you to download mailbox categories locally.
  • Built-in date filter – allows you to export only the required data based on a specific date range.
  • It also offers a category filter so that you can only export specific folders.
  • Using the admin credentials you can download bulk user mailbox data.
  • It provides a built-in dashboard to track the ongoing export process.

Tool Steps to Perform 

  • Step 1. Download, install, and launch the software on a PC.
  • Step 2. Choose Office 365 as the source and Outlook as a destination. 
  • Step 3. Enable required mailbox categories and set date filter.
  • Step 4. Login with Source Office 365 Admin Credentials.
  • Step 5. Select user accounts to export and click on start.

Demo version – You can download the demo version of this utility for free. It allows you to export two user accounts, using this you can check the software’s performance and reliability. 

Wrapping Up

Since there are different types of Microsoft 365 groups available in Office 365. Hence, it becomes crucial to manage them efficiently. Due to this administrators and users are often required to export Office 365 group members to CSV files, to leverage the data for various administrative tasks within the organization.

Therefore, In this detailed write-up, we have discussed two ways i.e. using Admin Center and PowerShell, using which you can easily export Office 365 group members to CSV.

  author

By Mohit Jha

Mohit is a writer, researcher, and editor. Cyber ​​security and digital forensics are the two subjects that keep Mohit out of his seat. In addition, he hopes that the well-researched and thought-out articles he finds will help people learn.