Skip to content

ActiveDirectory module

Retrieve Active Directory User

Terminal window
Get-ADUser -Identity JohnSmith

Retrieve All Properties Associated with User

Terminal window
Get-ADUser -Identity JohnSmith -Properties *

Retrieve Selected Properties for User

Terminal window
Get-ADUser -Identity JohnSmith -Properties * | Select-Object -Property sAMAccountName, Name, Mail

New AD User

Terminal window
New-ADUser -Name "MarySmith" -GivenName "Mary" -Surname "Smith" -DisplayName "MarySmith" -Path "CN=Users,DC=Domain,DC=Local"
Terminal window
#Add the ActiveDirectory Module to current PowerShell Session
Import-Module ActiveDirectory

Retrieve Active Directory Group

Terminal window
Get-ADGroup -Identity "My-First-Group" #Ensure if group name has space quotes are used

Retrieve All Properties Associated with Group

Terminal window
Get-ADGroup -Identity "My-First-Group" -Properties *

Retrieve All Members of a Group

Terminal window
Get-ADGroupMember -Identity "My-First-Group" | Select-Object -Property sAMAccountName
Get-ADgroup "MY-First-Group" -Properties Members | Select -ExpandProperty Members

Add AD User to an AD Group

Terminal window
Add-ADGroupMember -Identity "My-First-Group" -Members "JohnSmith"

New AD Group

Terminal window
New-ADGroup -GroupScope Universal -Name "My-Second-Group"

Retrieve AD Computer

Terminal window
Get-ADComputer -Identity "JohnLaptop"

Retrieve All Properties Associated with Computer

Terminal window
Get-ADComputer -Identity "JohnLaptop" -Properties *

Retrieve Select Properties of Computer

Terminal window
Get-ADComputer -Identity "JohnLaptop" -Properties * | Select-Object -Property Name, Enabled

Retrieve an Active Directory Object

Terminal window
#Identity can be ObjectGUID, Distinguished Name or many more
Get-ADObject -Identity "ObjectGUID07898"

Move an Active Directory Object

Terminal window
Move-ADObject -Identity "CN=JohnSmith,OU=Users,DC=Domain,DC=Local" -TargetPath "OU=SuperUser,DC=Domain,DC=Local"

Modify an Active Directory Object

Terminal window
Set-ADObject -Identity "CN=My-First-Group,OU=Groups,DC=Domain,DC=local" -Description "This is My First Object Modification"

Please remember that PowerShell’s Help System is one of the best resources you can possibly utilize.

Terminal window
Get-Help Get-ADUser -Full
Get-Help Get-ADGroup -Full
Get-Help Get-ADComputer -Full
Get-Help Get-ADObject -Full

All of the help documentation will provide examples, syntax and parameter help.