Quick commandline to get AD group membership

This line is handy for quickly exporting an Active Directory groups membership list to a text file.  Open the file as delimited in excel to make deciphering the LDAP a bit easier.

dsquery group -samid <groupname> | dsget group -members > %temp%\users.txt

this one will only show samid:

dsquery group -samid <groupname> | dsget group -members | dsget user -samid > %temp%\users.txt

 

In Powershell:

Get-ADGroupMember <groupname>

This one obtains the group membership a specific user –

Get-ADUser <username> -Properties MemberOf | Select -ExpandProperty memberof