Active Directory with PowerShell

Active Directory module for Windows PowerShell

Regular used command with examples.


Cmdlet
Get user
Get-ADUser
Create user

Modify user

Delete user
Remove-ADUser


Get group

Create group

Modify group

Delete group



Get group member

Add group member

Modify group member



Get computer
Get-ADComputer
Create computer
New-ADComputer
Modify computer

Delete computer


Audit report command with examples.


Cmdlet
User not login to AD from last one month

Computer not contact



















Get user



Create user

Modify user

Delete user

Disables an Active Directory account.
PS C:\> Disable-ADAccount -Identity "ravindra.sharma"

Enables an Active Directory account.
PS C:\> Enable-ADAccount -Identity "ravindra.sharma"



Get group

Create group

Modify group

Delete group



Get group member

Add group member

Modify group member


Get computer

Get all computer details
PS C:\> Get-ADComputer -Filter * | Select-Object Name, DNSHostName, DistinguishedName, Enabled | Format-Table -AutoSize

PS C:\> Get-ADComputer -Filter * | Select-Object Name, DNSHostName, DistinguishedName, Enabled | Export-Csv C:\AD-Computer.csv –NoTypeInformation

Get computer details which contains computer name NOI with IP address
C:\PS> Get-ADComputer -Filter 'Name -like "*NOI*"' -Properties IPv4Address | FT Name, DNSHostName, IPv4Address -A

Get computer count
PS C:\> (Get-ADComputer -Filter *).Count

Get computer detail information
PS C:\> Get-ADComputer -Identity "DESKTOP-NAME" -Properties *

Get computer detail based on OU
PS C:\> Get-ADComputer -LDAPFilter "(name=*)" -SearchScope Subtree -SearchBase " OU=HR_Core,OU=HR,DC=company,DC=local" | Select-Object Name, DNSHostName, DistinguishedName, Enabled | Export-Csv C:\AD-ComputerOU.csv –NoTypeInformation



Create computer

Modify computer

Delete computer


Post a Comment

0 Comments