Move Multiple Users to a different OU with Powershell

MilesLogan
MilesLogan used Ask the Experts™
on
Hi EE

I need to move 20,000 users to a new OU and wanted to get some insight from the experts if the line below is sufficient or am I risking something or a better way to get it accomplished  ?


gc users.txt | Get-ADUser | Move-ADObject -TargetPath "DC=OU,DC=Test,DC=New,DC=My"
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hello,

your line of script is fine , If I were you  , I would have divide that 20000 users in 4 , 5000 each and moved the users to the OU at specific time interval.

This is just to make sure , not over burden the inter site replication.

Thanks,

-Prashant Girennavar.
Matt MinorTechnical Systems Analyst
Commented:
You don't have any OU object in your TargetPath.

OU=US,DC=mydomain,DC=net

Correct that part and everything else looks like it should work fine.
Commented:
In the future if you want to preview what your command will do prior to actually running it, just append it with -WhatIf.  If it doesn't tab-complete it's a pretty good sign something is wrong:

Get-Content .\users.txt | Get-ADUser | Move-ADObject -TargetPath 'OU=US,DC=mydomain,DC=net' -WhatIf

Open in new window

Author

Commented:
Thanks all !

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial