03 02 Powershell - connorethanjay/Champlain-College-CNCS-Notes GitHub Wiki

Quickly writing this since there isn't much new info other than the powershell commands.

Creating an OU via Powershell

  • New-ADOrganizationalUnit OU_NAME

Removing an OU via Powershell

  • Remove-ADOrganizationalUnit OU_NAME
    • Be more specific with the path of the OU since there can of course be errros. eg -Identity "OU=OU_NAME,DC=connorjay,DC=local"

Moving an object within AD

  • Move-AdObject -Identity (can be combined with commands eg. Get-ADUser connor.jay or Get-ADComputer WKS01-CONNORJAY) -TargetPath "OU=OU_NAME,DC=connorjay,DC=local"

Searching Event Logs via Powershell

  • Get-EventLog
    • -LogName System (or something else)
    • -EntryType eg. Information
    • -ComputerName Example
    • -Username Example
    • -InstanceID 123
    • -Before / -After