Move Bulk AD user from One OU to another using Powershell.

As of the transfer with in the organization of different departments or branch happens, it is hetic job for the IT Admin to manage all the users from one OU to another. Doing it manually really kills the time and makes insane. So here, i have create a script that could help IT admin to get relief of such hetic job. In this script I made a source as a CSV file where IT Admin can just have a user CN and Target OU and boom every users will get transfer to the desired OU.

#################################################################
# This script will help yo move bulk ad accounts into target OU
# Written 04/04/2016 Prashant,Dhewaju
# Fell free to change use any part of this script
# http://pdhewaju.com.np
#################################################################
# Import AD Module
import-module ActiveDirectory

# Import CSV
# Import the data from CSV file and assign it to variable
$Imported = Import-Csv -Path "C:\temp\move.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"

Download script and sample CSV format from this link

20 Comments

Add a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.