Quick answer
Get-ADGroupMember lists the members of one Active Directory group. Pass the group's SAM account name, distinguished name, GUID or SID:
Get-ADGroupMember -Identity Administrators
To include the members of nested groups, add -Recursive:
Get-ADGroupMember -Identity "Enterprise Admins" -Recursive
The cmdlet is part of the ActiveDirectory module. If PowerShell doesn't recognize it, install the Remote Server Administration Tools (RSAT). On Windows 10 from the October 2018 Update onward, RSAT is a set of Features on Demand: open Manage optional features in Settings, choose Add a feature and pick the Active Directory tools.
What does Get-ADGroupMember do?
It reads the member list of a group in Active Directory Domain Services or an AD LDS instance. Members can be users, groups and computers. Each result is a principal object with these properties:
| Property | Example |
|---|---|
distinguishedName |
CN=LabAdmin,CN=Users,DC=Fabrikam,DC=com |
name |
LabAdmin |
objectClass |
user, group or computer |
objectGUID |
The member's GUID |
SamAccountName |
LabAdmin |
SID |
The member's security identifier |
It has one parameter set. -Identity is the only required parameter, and it's positional, so Get-ADGroupMember Administrators works too.
Related cmdlets in the same module:
| Cmdlet | What it does |
|---|---|
Get-ADGroup |
Gets the group object itself |
Add-ADGroupMember |
Adds members to a group |
Remove-ADGroupMember |
Removes members from a group |
Get-ADPrincipalGroupMembership |
Works the other way round: lists the groups a user, computer or group belongs to |
For groups in Microsoft Entra ID, use Get-MgGroupMember instead.
Examples
| Goal | Command |
|---|---|
| Members of one group | Get-ADGroupMember -Identity Administrators |
| Members including nested groups | Get-ADGroupMember -Identity "Enterprise Admins" -Recursive |
| Pipe in a group from Get-ADGroup | Get-ADGroup -Identity Administrators | Get-ADGroupMember |
| Names only | Get-ADGroupMember -Identity Administrators | Select-Object name,SamAccountName |
| Users only, no nested groups or computers | Get-ADGroupMember -Identity Administrators | Where-Object objectClass -eq 'user' |
| Count the members | (Get-ADGroupMember -Identity Administrators).Count |
| Members of every domain local group in AD LDS | Get-ADGroup -Server localhost:60000 -Filter "GroupScope -eq 'DomainLocal'" -SearchBase "DC=AppNC" | Get-ADGroupMember -Partition "DC=AppNC" |
What does -Recursive return?
Without -Recursive, a nested group shows up as one member with objectClass set to group. Its own members aren't listed.
With -Recursive, the cmdlet walks the whole hierarchy and returns only the members that don't contain child objects. Microsoft's example: if the group SaraDavisReports contains the user KarenToh and the group JohnSmithReports, and JohnSmithReports contains the user JoshPollock, the recursive result is KarenToh and JoshPollock. The JohnSmithReports group itself isn't in the list.
If the group has no members, -Recursive returns nothing.
How do I export group members to CSV?
The default output has no email address or department, so look each user up with Get-ADUser for the extra fields. A distinguished name works as the identity:
Get-ADGroupMember -Identity "Finance Team" |
Where-Object objectClass -eq 'user' |
ForEach-Object { Get-ADUser -Identity $_.distinguishedName -Properties mail } |
Select-Object Name,SamAccountName,mail |
Export-Csv finance-team.csv -NoTypeInformation
See Get-ADUser for the -Properties rules. To keep full objects instead of a flat file, use Export-Clixml.
How do I read the member attribute instead?
Get-ADGroup can return the group's member attribute, a list of distinguished names:
Get-ADGroup -Identity S-1-5-32-544 -Properties member
That gives you the raw list on the group object. Get-ADGroupMember gives you one object per member, with the class, SAM account name and SID already filled in, which is easier to filter and pipe.
Which server and partition does it use?
| Parameter | What it does | Default |
|---|---|---|
-Server |
The domain or directory server to ask, by FQDN or NetBIOS name, with an optional port | The server of a piped-in object, then the AD provider drive's server, then the domain of the computer running PowerShell |
-Partition |
The partition to find the group in | Taken from a distinguished-name identity, then the provider drive path, then the domain's default naming context |
-Credential |
The account to run as | The signed-in user, or the account mapped to the AD provider drive |
-AuthType |
Negotiate or Basic |
Negotiate. Basic needs an SSL connection |
In AD LDS, you must pass -Partition unless you run the cmdlet from an AD provider drive or the instance has a default naming context. To add one, set msDS-defaultNamingContext on the instance's directory service agent object (nTDSDSA).
To run as another account, build a credential first. See Get-Credential.
$cred = Get-Credential
Get-ADGroupMember -Identity "Finance Team" -Credential $cred -Server dc01.contoso.com
Why doesn't Get-ADGroupMember work?
| Symptom | Likely cause | Fix |
|---|---|---|
| The term Get-ADGroupMember isn't recognized | The ActiveDirectory module isn't installed | Add the RSAT Active Directory tools from Manage optional features |
| Nested group members are missing | The command ran without -Recursive |
Add -Recursive |
| A nested group is missing from the results | -Recursive lists only members without child objects |
Run it without -Recursive to see the nested groups |
A field such as mail is missing |
It isn't in the member object's property set | Look the member up with Get-ADUser -Properties |
| An error about more than one object | Two objects match the identity | Use the distinguished name, GUID or SID |
| It can't find the group in AD LDS | No partition was given and there's no default naming context | Pass -Partition |
| An access error stops the command | The account has no directory-level rights for the task | Run with -Credential for an account that does |
| It fails on a group with members in another forest | That forest isn't running Active Directory Web Services | Run Active Directory Web Services in that forest |
| Nothing works against a snapshot | Get-ADGroupMember doesn't support Active Directory snapshots | Query a live domain controller |
How do I check the result?
Compare the count with and without -Recursive:
(Get-ADGroupMember -Identity "Finance Team").Count
(Get-ADGroupMember -Identity "Finance Team" -Recursive).Count
A gap between the two means the group has nested groups. Then check one person you expect to find from the other side. Get-ADPrincipalGroupMembership needs a global catalog in the forest.
Get-ADPrincipalGroupMembership -Identity amyc | Select-Object name
For a direct member, the group should be in that list.
Sources
- Get-ADGroupMember on Microsoft Learn
- Get-ADGroup on Microsoft Learn
- Get-ADPrincipalGroupMembership on Microsoft Learn
- ActiveDirectory module on Microsoft Learn
Meeting Room 365 turns any iPad or Android tablet into a room display for Exchange and Microsoft 365 calendars. See the features or pricing: $9 a room a month.