Querying Active Directory with Powershell

View members in a group:

Get-ADGroupMember -identity groupname | sort name | select-object -expand Name


Same as above, but does a recursive search through all sub-groups:

Get-ADGroupMember -identity groupname -Recursive | sort name | select-object -expand Name


View groups a single person is in:

Get-ADPrincipalGroupMembership username | select name,distinguishedName | sort distinguishedName

Leave a comment