Get-ADPrincipalGroupMembership

Get the Active Directory groups that have a specified user, computer, group, or service account.

Syntax
      Get-ADPrincipalGroupMembership [-Identity] ADPrincipal 
         [-AuthType {Negotiate | Basic}] [-Credential PSCredential]
            [-Partition string] [-ResourceContextPartition string]
               [-ResourceContextServer string] [-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 ADPrincipal
       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 the Partition parameter if no value
       is specified.
        
   -ResourceContextPartition string
The distinguished name of the partition of an AD or AD LDS instance to search. Use this parameter with the -ResourceContextServer parameter to specify a partition hosted by the specified server. If the ResourceContextPartition parameter is not specified, the default partition of the ResourceContextServer is searched.

The following example shows how to set this parameter.
-ResourceContextPartition "cn=employees,dc=corp,dc=ss64,dc=com"

-ResourceContextServer string
Specify that the cmdlet return a list of groups that the user is a member of and that reside in the specified domain. Use this parameter to search for groups in a domain that is not the domain where the user's account resides. To search a partition other than the default partition in this domain, also specify the -ResourceContextPartition parameter.

The following example shows how to specify this parameter.
-ResourceContextServer "corp.ss64.com" -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-ADPrincipalGroupMembership gets the AD groups that have a specified user, computer, group, or service account as a member. This cmdlet requires a global catalog to perform the group search.
To search for local groups in another domain, use the -ResourceContextServer parameter to specify the alternate server in the other domain.

The -Identity parameter specifies the user, computer, or group object to be examined. Identify a user, computer, or group object by its distinguished name (DN), GUID, security identifier (SID) or SAM account name. You can also specify a user, group, or computer object variable, or pass an object through the pipeline. For example, use Get-ADGroup to retrieve a group object and then pass the object through the pipeline to Get-ADPrincipalGroupMembership. Similarly, Get-ADUser or Get-ADComputer may be used to get user and computer objects to pass through the pipeline.

Examples

Retrieve all the groups the user 'CN=Simon,DC=AppNC' is a member of on an AD LDS instance:

PS C:\> get-adprincipalgroupmembership -server localhost:60000 -identity "CN=Simon,DC=AppNC" -partition "DC=SS64"

Retrieve all the groups the administrator is a member of:

PS C:\> get-adprincipalgroupmembership -Identity Administrator

Retrieve all the groups the adminIstrator account in the local domain is a member of in the resource domain france.ss64.com:

PS C:\> get-adprincipalgroupmembership -Identity Administrator -ResourceContextServer france.SS64.com -ResourceContextPartition "DC=SS64,DC=com"

“You know it is not in my Interest to pay the Principal; nor is it my Principal to pay the Interest” ~ Richard Brinsley Sheridan

Related:

Add-ADPrincipalGroupMembership - Add a member to one or more AD groups.
Remove-ADPrincipalGroupMembership - Remove a member from one or more AD groups.
Get-adAccountAuthorizationGroup - Get the groups in which an account is a direct or indirect member.


© Copyright SS64.com 1999-2014
Some rights reserved