Others

Export Microsoft 365 Security Group Members to CSV with PowerShell

Anum MushtaqAnum Mushtaq Nov 27, 2026 871 views

Question details

Export the members of a Microsoft 365 security group to a CSV file using PowerShell.

Export Microsoft 365 Security Group Members to CSV with PowerShell
Product
Microsoft 365 and Microsoft Graph PowerShell
Device & OS
not provided
Scenario
A tenant administrator needs a CSV list of a security group's members.
Observed behavior
The desired output is a CSV file containing member details for the selected security group.
Before you start

Have the security group's name or object ID ready, and use an account that can consent to or has been granted the required Microsoft Graph permissions. The older MSOnline module and its Connect-MsolService commands are retired; use Microsoft Graph PowerShell instead.

Solution 1Recommended

Export direct group members with Microsoft Graph PowerShell

Use this method to retrieve direct members of a security group and save their available details to CSV.

The export lists direct members, not members of nested groups. Some properties may be blank if they do not apply to a member type or your account lacks permission to read them.

The Microsoft Graph v1.0 group-members endpoint has a known limitation that can omit service principals. Check the Microsoft Graph documentation for alternatives if your group contains service principals.

1
Install the Graph modules

Open PowerShell and run: Install-Module Microsoft.Graph.Authentication, Microsoft.Graph.Groups -Scope CurrentUser. Approve any installation prompts.

2
Connect to Microsoft Graph

Run Connect-MgGraph -Scopes 'GroupMember.Read.All' and sign in to the correct tenant. Administrator consent or additional permissions may be needed to read details for some member types.

3
Find the group ID

If you do not already have the object ID, run Get-MgGroup -All | Where-Object { $_.SecurityEnabled -eq $true -and $_.DisplayName -eq 'Your group name' } | Select-Object DisplayName, Id. Replace the group name and copy the Id of the intended group.

4
Export the members

Replace the group ID and, if needed, the output path in this command: Get-MgGroupMember -GroupId 'group-object-id' -All -Property Id,DisplayName,Mail | Select-Object @{Name='DisplayName';Expression={$_.AdditionalProperties['displayName']}}, @{Name='EmailAddress';Expression={$_.AdditionalProperties['mail']}}, @{Name='MemberType';Expression={$_.OdataType}}, Id | Export-Csv -Path '.\security-group-members.csv' -NoTypeInformation -Encoding UTF8.

5
Check the CSV

Open security-group-members.csv from PowerShell's current directory in a spreadsheet application and review the rows and available fields. Run Get-Location in PowerShell if you need to find that directory.

Export direct group members with Microsoft Graph PowerShell
Empty or incomplete results: Confirm the group ID and permissions if expected members or details are missing. An empty group may not produce a CSV file through this pipeline.
Free Microsoft Office alternative

Review exported group member lists in WPS Spreadsheet

After exporting the CSV with Microsoft Graph PowerShell, use free, lightweight WPS Office to review and organize the list. Its familiar interface and Microsoft Office format compatibility make it easy to move spreadsheet work between applications.

Open and review exported security group member CSV filesWork with Microsoft Excel XLSX and XLS filesUse a familiar spreadsheet interface for sorting and filteringAccess a free, lightweight Office alternative
microsoft office alternative - wps office

Frequently Asked Questions

Can I still use Connect-MsolService to export group members?

The MSOnline module is retired. Use Connect-MgGraph and Get-MgGroupMember from Microsoft Graph PowerShell instead.

How do I find the security group's object ID?

After connecting with Connect-MgGraph, run Get-MgGroup -All and filter by the group's DisplayName and SecurityEnabled properties. The Id field is the group object ID.

Does the export include members of nested groups?

No. Get-MgGroupMember returns direct members. A nested group can appear as a member, but its own members are not expanded by this command.

Why are some names or email addresses blank?

Some member types do not have a mail address, and Microsoft Graph may return limited details when your account lacks permission to read a member's resource type. Check the member type and your granted permissions.