Monday, November 05, 2018

Windows Active Directory Groups/ Roles

To list a users Active Directory groups run this

net user /domain

Problem with this is that it is limited to 21 characters.

Here is a Windows Powershell command to do the same (less memorable though)

(New-Object System.DirectoryServices.DirectorySearcher("(&(objectCategory=User)(samAccountName=$($env:username)))")).FindOne().GetDirectoryEntry().memberOf
or
([ADSISEARCHER]"samaccountname=$($env:USERNAME)").Findone().Properties.memberof