How to move OU members into other OU based on sAMaccountname or other attribute

Eaven HUANG 2,126 Reputation points

Dear friend,

We have an OU containing around 1000+ members and we will need to create sub-OU to separate them. We will create 10 sub-OUs and move them into different ones. I have an excel list containing the members' E-mail, sAMAccountName, can we do this in bulk based on their E-mail field or sAMAccountName attribute?

Many thanks in advance for any assistance.

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,289 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 31,171 Reputation points Microsoft Vendor


    You can create a script to do this. The Move-ADObject cmdlet moves an AD object to a specific container.

    $sAMAccountName = "someuser"  
    $ou = "OU=test,DC=contoso,DC=com"  
    Get-ADUser -Identity $sAMAccountName | Move-ADObject -TargetPath $ou  

    Best Regards,
    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 additional answers

Sort by: Most helpful