~/export a list of members from an active directory group
Four ways to export AD group membership to a file: net group, dsquery, PowerShell, and Microsoft Graph for Entra ID groups.
Updated November 2026. The 2012 commands still work. PowerShell is now the better option, and I’ve added Entra ID groups too.
In every example, replace Group Name with the name of your group.
Quick and simple: net group
net group "Group Name" /domain > memberlist.txt
This gives you a list of usernames. It’s handy for a quick look, but the output is in columns and awkward to reuse.
With full distinguished names: dsquery and dsget
dsquery group -name "Group Name" | dsget group -members > memberlist.txt
This returns each member’s full distinguished name, which shows which OU each account sits in.
The better way today: PowerShell
With the Active Directory module (part of RSAT), export straight to CSV:
Get-ADGroupMember -Identity "Group Name" -Recursive |
Select-Object Name, SamAccountName, ObjectClass, DistinguishedName |
Export-Csv memberlist.csv -NoTypeInformation
-Recursiveincludes members of nested groups. Leave it out for direct members only.- The CSV opens straight in Excel.
Very large groups (over about 5,000 members) can hit a size limit with Get-ADGroupMember. For those, read the member attribute directly:
Get-ADGroup "Group Name" -Properties member |
Select-Object -ExpandProperty member |
Out-File memberlist.txt
Entra ID (cloud) groups
For Microsoft 365 or Entra ID groups, use the Microsoft Graph PowerShell SDK:
Connect-MgGraph -Scopes "GroupMember.Read.All"
$group = Get-MgGroup -Filter "displayName eq 'Group Name'"
Get-MgGroupMember -GroupId $group.Id -All |
Select-Object Id, @{n='DisplayName'; e={$_.AdditionalProperties.displayName}},
@{n='UPN'; e={$_.AdditionalProperties.userPrincipalName}} |
Export-Csv memberlist.csv -NoTypeInformation
For a one-off, you can also download the member list as a CSV from the group’s Members page in the Entra admin centre.