User Tools

Site Tools


active_directory

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
active_directory [2019/09/03 02:01] stephenactive_directory [2021/04/06 09:01] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Active Directory ====== ====== Active Directory ======
 +
 +===== Basic Account Check =====
 +
 +<code powershell>
 +net user username /domain
 +</code>
  
 ===== Get Group Membership ===== ===== Get Group Membership =====
 +
 +To get just the top level groups:
 +<code powershell>
 +Get-ADPrincipalGroupMembership -Identity $env:username | Select name, GroupCategory, GroupScope, distinguishedName
 +Get-ADPrincipalGroupMembership -Identity 'username' | Select name, GroupCategory, GroupScope, distinguishedName
 +</code>
 +
 +To get **all** groups:
 +<code>
 +whoami /groups
 +whoami /groups | out-file group.txt
 +</code>
 +
 +===== 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. 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.
 <code> <code>
 gpresult /R gpresult /R
-</code> 
- 
-Try this: 
-<code powershell> 
-Get-ADPrincipalGroupMembership -Identity $env:username | Select name 
-Get-ADPrincipalGroupMembership -Identity 'username' | Select name 
 </code> </code>
  
Line 28: Line 42:
 <code powershell> <code powershell>
 (New-Object System.DirectoryServices.DirectorySearcher("(&(objectCategory=User)(samAccountName=$($env:username)))")).FindOne().GetDirectoryEntry().memberOf (New-Object System.DirectoryServices.DirectorySearcher("(&(objectCategory=User)(samAccountName=$($env:username)))")).FindOne().GetDirectoryEntry().memberOf
 +</code>
 +
 +===== Get Local Admins =====
 +
 +<code>
 +net localgroup administrators
 +</code>
 +
 +===== Get Members of a Group =====
 +
 +<code powershell>
 +Get-ADGroupMember "X3 NZ Provoke Developers" -Recursive
 </code> </code>
  
active_directory.1567476094.txt.gz · Last modified: 2019/09/04 03:01 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki