MS Windows – List Groups a user belongs to

Background

Let us use built-in tools to review our Active Directory group memberships.

Outline

  1. whoami
    • whoami /groups
  2. dsquery
    • dsquery | dsget

Machine

whoami

whoami – List Local Groups

Script

whoami /groups /fo csv | find /V "%USERDOMAIN%\" | more

Output

whoami – List Domain Groups

Script

whoami /groups /fo csv | find "%USERDOMAIN%\" | more

 

Domain

dsquery

dsquery | dsget

Script

dsquery user -samid %username% | dsget user -memberof

Output

dsquery_dsget_20170929_0400pm.png

References

  1. whoami
    • Command Line Reference
      Link
    • John Savill
      • How can I determine which groups I’m a member of for my current logon session?
        Link
  2. dsquery // dsget
    • ss64.com
      • DSQuery user (installable option either via RSAT /AD DS or adminpack.msi)
        Link
      • StackExchange
        • superuser.com
          • Using the “net user” command in Windows XP to list all group memberships for a specific Active Directory user
            Link