Powershell – Move Accounts from .txt file to new OU

$users = Import-Csv -Path “C:\Temp\useraccounts.csv”
$TargetOU = “OU=Disabled_IN,OU=Users,OU=Denver,DC=143IT,DC=com”

$users | ForEach-Object {
# Get ad user
$users = (Get-ADUser -Identity $_.SAMAccountName).distinguishedName
Write-Host “Move ad user” $users
# Move user to target OU
Move-ADObject -Identity $users -TargetPath $TargetOU
}

Leave a Reply

Your email address will not be published. Required fields are marked *