This script will move computers in a multi-domain forest from one Organizational Unit to another.
#################################################################
# This script will help to move bulk ad computer accounts into target OU
#################################################################
#Importing AD Module
Write-Host " Importing AD Module..... "
import-module ActiveDirectory
Write-Host " Importing Move List..... "
# Reading list of computers from csv and loading into variable
$MoveList = Import-Csv -Path "C:\Temp\PC_Move_List.csv"
# defining Target Path. Change the Target OU path as per your domain.
$TargetOU = 'OU=Computers,DC=SolutionsIT,DC=net'
$countPC = ($movelist).count
Write-Host " Starting import computers ..."
foreach ($Computer in $MoveList){
Write-Host " Moving Computer Accounts..."
Get-ADComputer $Computer.Name -server "YourDomain" | Move-ADObject -TargetPath $TargetOU
}
Write-Host " Completed Move List "
Write-Host " $countPC Computers has been moved "
Note: In the CSV file, put Name as the first entry. So your .csv will look like this: Name Computer1 Computer2 Computer3
Comments