Home » Blog » Cloud Migration » Verified PowerShell Script to Move Multiple Users to Different OU Easily

Verified PowerShell Script to Move Multiple Users to Different OU Easily

author
Published By Aswin Vijayan
admin
Approved By Anuraag Singh
Published On October 4th, 2023
Reading Time 5 Minutes Reading
Category Cloud Migration
PowerShell script to move multiple users to different OU

PowerShell is made up of command line shell to automate cross platform tasks. PowerShell commands can be run on Windows OS, Linux, and Mac OS all versions. This post will guide you to move multiple users to different OU using PowerShell commands. Let us get started!

Before Proceeding Note: PowerShell is a scripting language command line that need to be perform with perfection. If you are not familiar with this, then you may find difficulty to perform the below task. In this case, you may find third party tools handy to move multiple users to another OU.

Methods to Move Users to Different OU

There are multiple ways to move multiple users to another organizational unit. All are listed below. Choose the method that best suites in your situation.

Let us explain each method in detail.

Method-1: Move AD Users to Different OU using PowerShell Script

My recommendation is to use Move-AdObject command to easily move AD users to different OU. Perform below listed script:

Note: This command will allow you to move single users to other OU at a time.

Get-ADUser -Identity Mack.John | Move-ADObject -TargetPath “OU=Marketing,DC=VMLAB,DC=LOCAL”

AD admin can understand this command easily but for novice users it is very hard to understand it. So, let us understand this PowerShell command in details.

This command contains two different sections, in the first section it instructs to fetch the user from source i.e. Mack.John.

In the second phase you need to select the destination Organizational Unit. The command will pick the user from source and move to selected destination OU i.e., Marketing in this case.

Method-2: Move Users to Organizational Unit using CSV File

Using CSV file for user authentication and destination selection can help to move multiple users to different OU at the same time.

Command given below to move multiple users to different OU using CSV has been listed below. Simply follow the instructions and get migrated.

$adUsers = Import-Csv -Path “C:\PowerShell\moveuser.csv”
$TargetOU = “OU=Marketing,DC=VMLAB,DC=LOCAL”
$adUsers | ForEach-Object {

# Get ad user
$aduser = (Get-ADUser -Identity $_.SAMAccountName).distinguishedName

Write-Host “Move ad user” $aduser

# Move user to target OU
Move-ADObject -Identity $aduser -TargetPath $TargetOU
}

The above command seems quite confusing and a non tech user cannot understand it properly. Get detailed explanation of each section:

Import-Csv: This command allows to import the CSV file from the specified path. After that fetch the information from CSV and store it into $adUsers variable.

$TargetOU: Variable to will contain the destination OU path to move user to different OU.
The process will continue for all entries of CSV file.

Method-3: Move Multiple Users to Different OU Using Professional Tool

PowerShell command are tedious to execute and can occur error while moving AD user to different OU. To overcome all shortcomings of PowerShell commands, SysTools developed an advanced Active Directory Migrator Software. It allows to migrate multiple users to different OU without any limitation.
The software is developed with cutting edge technology, so anyone can use it. It makes the migration process quite easy. Let us discuss the working steps:

Steps to Move AD Users to OU Directly

Follow the below listed steps and move all users without any limitation.

Download for Windows Purchase Now

Step-1: Download and install the software on your system. After that login using your Administrator credentials. For this provide User ID, Password and hit LOGIN button.

PowerShell script to move multiple users to different OU

Step-2: Do mouse click on Register Domain Controller and provide required details like: Domain Friendly Name and IP Address. Provide same details for destination domain also.

verified steps

 

Step-3: Now the new window will appear with the list of Source and Destination domain. From this screen you need to fetch the objects from source domain and match it with the destination.

list of AD users

Step-4: Create migration scenario by tapping on Migration option from left bar. Here provide scenario name and select source and destination. After that hit Save & Continue button and Create Task.

migration task

Step-5: Its time to select objects that you want to move source user to other OU. Simply select User and then map the objects with destination OU.

move users to different OU

Step-6: Now a window will appear names as Migration Options, select the Create radio button and hit Select.

choose create option

Step-7: After completing the user migration to different AU, the tool will show the progress report. Check status, if completed means you have successfully moved multiple users to different AU directly.

powershell script to move users to another ou from csv

Conclusion

This write-up is intended to help users to move multiple users to different AU using PowerShell cmdlet. 3 different methods are explained in above sections. Find the best one that suites in your situations.

Author’s Recommendation: If you are techie and AD administrator then you give a try to PowerShell commands. Otherwise, its better go with third-party software to easy and error less process to move AD users to different AU.

Get expert guide on how to migrate computer from one domain to another