Link to home
Start Free TrialLog in
Avatar of Murty M
Murty MFlag 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.
Avatar of oBdA
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

Avatar of 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.
So how do you identify the users that need moving? Do you have a csv with SamAccountNames?
Avatar of Murty M

ASKER

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

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial