PowerShell Genie

Get-ADGroupMember

Use Get-ADGroupMember to list the members of an Active Directory group, optionally expanding nested groups.

Command 1 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Get-ADGroupMember

Syntax

1PS> Get-ADGroupMember [-Identity] <ADGroup> [-Recursive] [-Partition <String>] [-Server <String>] [-Credential <PSCredential>] [<CommonParameters>]
See the command anatomy

Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

Get-ADGroupMember [-Identity] <ADGroup> [-Recursive] [-Partition <String>] [-Server <String>] [-Credential <PSCredential>] [<CommonParameters>]
  1. Stage 1Get-ADGroupMember-Identity -Recursive -Partition -Server -Credential

    Try it

    Windows PowerShell

    Browser simulation · fictional data; no changes to your computer.

    Interactive simulation · fictional data

    Examples

    Get-ADGroupMember -Identity "Domain Admins"

    1PS> Get-ADGroupMember -Identity "Domain Admins" -Recursive | Select-Object Name, SamAccountName
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Name        SamAccountName
    ----------  --------------
    Jane Smith  jsmith
    Alex Jones  ajones

    Get-ADGroupMember -Identity "Sales-Read"

    1PS> Get-ADGroupMember -Identity "Sales-Read" | Group-Object objectClass -NoElement
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Count  Name
    -----  ----
    2      SampleA
    1      SampleB

    Parameters

    Parameter definitions:

    • -Identity
    • -Recursive
    • -Partition
    • -Server
    • -Credential

    Get-ADGroupMember on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Get-ADGroupMember when you need to list the members of an Active Directory group, optionally expanding nested groups. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.

    Common error and fix: A membership query can fail when a referenced account cannot be resolved. Inspect the group and the identity in the error rather than treating a partial list as a complete access inventory. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.

    See also: Get-ADGroup. Get-ADGroup reads group objects and attributes; Get-ADGroupMember reads membership. The group's name and category do not enumerate its members. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Get-ADGroupMember reference on Microsoft Learn

    Put this command to work

    List group membership

    Import ActiveDirectory first. Read members of IT-Admins and return Name and SamAccountName.

    Review the lesson

    Recap

    Get-ADGroupMember Use Get-ADGroupMember to list the members of an Active Directory group, optionally expanding nested groups.

    Next: Add-ADGroupMember
    Genie guideGet-ADGroupMember

    Use Get-ADGroupMember to list the members of an Active Directory group, optionally expanding nested groups. The console below is pre-loaded — run it, then change a value and run it again.