We help IT Professionals succeed at work.

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

Murty M
Murty M asked
on
102 Views
Last Modified: 2019-02-27
PS Script Required:  move bulk users from one OU to other in same AD.
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2019
Most Valuable Expert 2018

Commented:
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

Author

Commented:
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.
CERTIFIED EXPERT
Most Valuable Expert 2019
Most Valuable Expert 2018

Commented:
So how do you identify the users that need moving? Do you have a csv with SamAccountNames?

Author

Commented:
Yes.  I have user names.
CERTIFIED EXPERT
Most Valuable Expert 2019
Most Valuable Expert 2018
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION