Get-ADGroupMember

Get the members of an Active Directory group.

Syntax
      Get-ADGroupMember [-Identity] ADGroup [-AuthType {Negotiate | Basic}]
         [-Credential PSCredential] [-Partition string]
            [-Recursive] [-Server string] [CommonParameters]

Key
   -AuthType {Negotiate | Basic}
       The authentication method to use: Negotiate (or 0), Basic (or 1)
       A Secure Sockets Layer (SSL) connection is required for Basic authentication.

   -Credential PSCredential
       The user account credentials to use to perform this task.
       The default credentials are those of the currently logged on user unless the
       cmdlet is run from an Active Directory PowerShell provider drive.
       If the cmdlet is run from such a provider drive, the account associated with the drive is the default.

       Type a user name, such as "User64" or "Domain64\User64" or specify a
       PSCredential object such as one generated by Get-Credential 

       If a user name is specified, the cmdlet will prompt for a password.

    -Identity ADGroup
       An Active Directory group object by providing one of the following values.
       (The identifier in parentheses is the LDAP display name for the attribute.)

          Distinguished Name 
            Example: CN=AnnualReports,OU=europe,CN=users,DC=corp,DC=SS64,DC=com 
          GUID (objectGUID) 
            Example: 599c3d2e-f72d-4d20-8a88-030d99495f20
          Security Identifier (objectSid) 
            Example: S-1-5-21-3165297888-301567370-576410423-1103
          Security Accounts Manager (SAM) Account Name (sAMAccountName)
            Example: AnnualReports

       The cmdlet searches the default naming context or partition to find the object.
       If two or more objects are found, the cmdlet returns a non-terminating error.

       This parameter can also get this object through the pipeline or you can set this
       parameter to an object instance.

       This example shows how to set the parameter to a distinguished name.
          -Identity  "CN=AnnualReports,OU=europe,CN=users,DC=corp,DC=SS64,DC=com"

       This example shows how to set this parameter to a group object instance named "ADGroupInstance".
          -Identity $ADGroupInstance
             
   -Partition string
       The distinguished name of an AD partition.
       The distinguished name must be one of the naming contexts on the current
       directory server. The cmdlet searches this partition to find the object defined by
       the -Identity parameter. 
       The following two examples show how to specify a value for this parameter.
          -Partition "CN=Configuration,DC=EUROPE,DC=TEST,DC=SS64,DC=COM"
         
          -Partition "CN=Schema,CN=Configuration,DC=EUROPE,DC=TEST,DC=SS64,DC=COM"

       In many cases, a default value will be used for -Partition if no value is specified.
   
   -Recursive
Specify that the cmdlet get all members in the hierarchy of a group that do not contain child objects. The following example shows a hierarchy for the group SS64.
+SS64 [group]
-Karen [user]
-Laptop65 [computer]
+SalesTeam [group]
-Julie [user]
-Armando [user]
+SalesComputers [group]
-PC21345 [computer]

If you specify SS64 as the group and specify the -Recursive parameter, the following members and sub
-members are returned.
Karen
Laptop65
Julie
Armando
PC21345

If the specified group does not have any members, then nothing is returned. -Server string The AD Domain Services instance to connect to, this may be a Fully qualified domain name, NetBIOS name, Fully qualified directory server name (with or without port number) CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer -OutVariable.

Get-ADGroupMember gets the members of an AD group. Members can be users, groups, and computers.

The -Identity parameter specifies the AD group to access. Identify a group by its distinguished name (DN), GUID, security identifier (SID), or Security Accounts Manager (SAM) account name or by passing a group object through the pipeline. For example, you can use Get-ADGroup to retrieve a group object and then pass the object through the pipeline to Get-ADGroupMember.

If the -Recursive parameter is specified, the cmdlet gets all members in the hierarchy of the group that do not contain child objects.

For AD LDS environments, the -Partition parameter must be specified except in the following two conditions:
-The cmdlet is run from an AD provider drive.
-A default naming context or partition is defined for the AD LDS environment. To specify a default naming context for an AD LDS environment, set the msDS-defaultNamingContext property of the Active Directory directory service agent (DSA) object (nTDSDSA) for the AD LDS instance.

Examples

Get all the members of the administrators groups using the default behavior:

PS C:\> get-adgroupmember -Identity "Administrators"

Get the group members of all domain local groups in the AD LDS instance:

PS C:\> get-adgroup -server localhost:60000 -filter {GroupScope -eq "DomainLocal"} _
-SearchBase "DC=AppNC" | get-adgroupmember -partition "DC=AppNC"

Get all the members of the 'Enterprise Admins' group including the members of any child groups:

PS C:\> get-adgroupmember "Enterprise Admins" -recursive

“Will you, won't you, will you, won't you, will you join the dance?” ~ Lewis Carroll

Related:

Get-ADGroup - Get an AD group
Get-QADGroupMember - Retrieve members of a group
Add-ADGroupMember - Add one or more members to an AD group


© Copyright SS64.com 1999-2014
Some rights reserved