Move AD users from one OU to another.

Requirements: Active Directory module, csv of usernames.

# Specify target OU. This is where users will be moved.
$TargetOU = "OU=Disabled Student Accounts,OU=Students,OU=Users,OU=FFA,DC=ffa,DC=local"
# Specify CSV path. Import CSV file and assign it to a variable. 
$Imported_csv = Import-Csv -Path "C:\MoveList.csv" 

$Imported_csv | ForEach-Object {
     # Retrieve DN of user.
     $UserDN  = (Get-ADUser -Identity $_.Name).distinguishedName
     # Move user to target OU.
     Move-ADObject  -Identity $UserDN  -TargetPath $TargetOU

 }

You may also like...