10.15.2015

Active Directory Commands and Cheatsheet and Powershell Scripts

Active Directory Commands and Cheatsheet

List Active Directory Groups that a user is a member of via CLI

net users <username> /domain

List all Active Directory Groups in a domain



net group /domain > c:\temp\domain-group-list.txt




Security Group which contains multiple domains
 
Group Scope : Domain local
Group type: Security

PowerShell script to List all groups and Members and export to a CSV


Import-Module ActiveDirectory
Get-ADUser -Filter * -Properties DisplayName,memberof | % {
  New-Object PSObject -Property @{
    UserName = $_.DisplayName
    Groups = ($_.memberof | Get-ADGroup | Select -ExpandProperty Name) -join ","
    }
} | Select UserName,Groups | Export-Csv C:\temp\report.csv -NTI

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.