Avatar of Murty M
Murty M
Flag for India asked on

PS Script Required: move bulk users from one OU to other in same AD

PS Script Required:  move bulk users from one OU to other in same AD.
Powershell

Avatar of undefined
Last Comment
oBdA

8/22/2022 - Mon
oBdA

Just all users found in the source OU?
In test mode, will only display which users it would move; remove the -WhatIf at the end to run it for real.
$sourceOU = (Get-ADOrganizationalUnit -Filter "name -eq 'Source'").DistinguishedName
$targetOU = (Get-ADOrganizationalUnit -Filter "name -eq 'Target'").DistinguishedName
Get-ADUser -Filter *  -SearchBase $sourceOU -ResultSetSize $null | Move-ADObject -TargetPath $targetOU -WhatIf

Open in new window

Murty M

ASKER
I have a single domain and different OUs in that domain.
There are like 2500 users in 30 OUs.
1. I need out of 2500 users, 400 users move in to Newly created OU -- First Script.
2. New users ( not part of these 2500) to add in to domain and part of new ou. -- Second Script.
oBdA

So how do you identify the users that need moving? Do you have a csv with SamAccountNames?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Murty M

ASKER
Yes.  I have user names.
ASKER CERTIFIED SOLUTION
oBdA

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question