ActiveDirectory module
Retrieve Active Directory User
Get-ADUser -Identity JohnSmithRetrieve All Properties Associated with User
Get-ADUser -Identity JohnSmith -Properties *Retrieve Selected Properties for User
Get-ADUser -Identity JohnSmith -Properties * | Select-Object -Property sAMAccountName, Name, MailNew AD User
New-ADUser -Name "MarySmith" -GivenName "Mary" -Surname "Smith" -DisplayName "MarySmith" -Path "CN=Users,DC=Domain,DC=Local"Module
Section titled “Module”#Add the ActiveDirectory Module to current PowerShell SessionImport-Module ActiveDirectoryGroups
Section titled “Groups”Retrieve Active Directory Group
Get-ADGroup -Identity "My-First-Group" #Ensure if group name has space quotes are usedRetrieve All Properties Associated with Group
Get-ADGroup -Identity "My-First-Group" -Properties *Retrieve All Members of a Group
Get-ADGroupMember -Identity "My-First-Group" | Select-Object -Property sAMAccountNameGet-ADgroup "MY-First-Group" -Properties Members | Select -ExpandProperty MembersAdd AD User to an AD Group
Add-ADGroupMember -Identity "My-First-Group" -Members "JohnSmith"New AD Group
New-ADGroup -GroupScope Universal -Name "My-Second-Group"Computers
Section titled “Computers”Retrieve AD Computer
Get-ADComputer -Identity "JohnLaptop"Retrieve All Properties Associated with Computer
Get-ADComputer -Identity "JohnLaptop" -Properties *Retrieve Select Properties of Computer
Get-ADComputer -Identity "JohnLaptop" -Properties * | Select-Object -Property Name, EnabledObjects
Section titled “Objects”Retrieve an Active Directory Object
#Identity can be ObjectGUID, Distinguished Name or many moreGet-ADObject -Identity "ObjectGUID07898"Move an Active Directory Object
Move-ADObject -Identity "CN=JohnSmith,OU=Users,DC=Domain,DC=Local" -TargetPath "OU=SuperUser,DC=Domain,DC=Local"Modify an Active Directory Object
Set-ADObject -Identity "CN=My-First-Group,OU=Groups,DC=Domain,DC=local" -Description "This is My First Object Modification"Remarks
Section titled “Remarks”Please remember that PowerShell’s Help System is one of the best resources you can possibly utilize.
Get-Help Get-ADUser -FullGet-Help Get-ADGroup -FullGet-Help Get-ADComputer -FullGet-Help Get-ADObject -FullAll of the help documentation will provide examples, syntax and parameter help.