User Tools

Site Tools


active_directory

This is an old revision of the document!


Active Directory

Get Group Membership

whoami /groups
whoami /groups | out-file group.txt

Get Group Membership - Alternatives

This generates a whole heap of crap - the security groups are at the end. This also seems to recurse down the groups or something - it lists more groups than the other options.

gpresult /R

Try this:

Get-ADPrincipalGroupMembership -Identity $env:username | Select name
Get-ADPrincipalGroupMembership -Identity 'username' | Select name

May need to install a module:

Install-WindowsFeature RSAT-AD-PowerShell

Also, try this:

get-aduser $env:username -Properties memberof | select -expand memberof
get-aduser 'username' -Properties memberof | select -expand memberof

Or, a module-free version:

(New-Object System.DirectoryServices.DirectorySearcher("(&(objectCategory=User)(samAccountName=$($env:username)))")).FindOne().GetDirectoryEntry().memberOf

Get Local Admins

net localgroup administrators

Get Members of a Group

Get-ADGroupMember "X3 NZ Provoke Developers" -Recursive
active_directory.1594160031.txt.gz · Last modified: 2020/07/08 23:13 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki