# Import AD Module
import-module ActiveDirectory
# Import CSV
# Import the data from CSV file and assign it to variable
$Imported = Import-Csv -Path "C:\tool\move-user.csv"
$Imported | ForEach-Object {
# Retrieve DN of User.
$UserDN = (Get-ADUser -Identity $_.Username).distinguishedName
$TargetOU = $_.TargetOU
Write-Host " Moving Accounts ..... "
# Move user to target OU.
Move-ADObject -Identity $UserDN -TargetPath $TargetOU
}
Write-Host " Completed move "
$total = ($Imported).count
Write-Host $total "User Moved Successfully"
官方文档:https://gallery.technet.microsoft.com/scriptcenter/Move-Bulk-AD-user-from-One-1d4cf28c