Home |

Trigat

Add computer to OU using PowerShell

10-16-2018

This quick PowerShell script allows you to move list of computers to specified OU in Active Directory

Language or Platform: Powershell

Code:

# Put list of computers in a file called computerlist.txt

$computerlist  = "$PSScriptRoot\computerlist.txt"
$list = gc $computerlist

foreach ($name in $list) {
    get-adcomputer $name | Move-ADObject -TargetPath 'ou=_Computers, ou=_SpecifiedName, dc=name, dc=local'
}

Back