Get-ADMemberOf
SYNOPSIS
Retrieves the group memberships of an Active Directory object.
SYNTAX
Get-ADMemberOf [-Identity] <String> [[-LDAPFilter] <String>] [[-Properties] <String[]>] [-Indirect]
[<CommonParameters>]
DESCRIPTION
The `Get-ADMemberOf` function retrieves the group memberships of an Active Directory object (e.g., user, computer, or other objects). It supports both direct and indirect group memberships and allows filtering using an LDAP filter. Additional properties of the groups can also be retrieved.
EXAMPLES
EXAMPLE 1
Retrieves the direct group memberships of the user "jdoe."
EXAMPLE 2
Retrieves both direct and indirect group memberships of the user "jdoe."
EXAMPLE 3
Retrieves the security group memberships of the user "jdoe."
PARAMETERS
-Identity
The identity of the Active Directory object (e.g., DistinguishedName, GUID, or SamAccountName).
Type: String
Parameter Sets: (All)
Aliases: DistinguishedName, DN
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
-LDAPFilter
An optional LDAP filter to refine the group membership query.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Properties
A list of additional properties to retrieve for each group. Defaults to common group properties.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: @('DistinguishedName', 'GroupCategory', 'GroupScope', 'Name', 'ObjectClass', 'ObjectGUID', 'SamAccountName', 'SID')
Accept pipeline input: False
Accept wildcard characters: False
-Indirect
A switch parameter that, when specified, retrieves indirect group memberships (nested groups).
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.