Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Move objects from one OU to another

Status
Not open for further replies.

humtake

MIS
Mar 12, 2004
2
0
0
US
I found this script online:
' This code moves objects from the "old" OU to the "new" OU
' ------ SCRIPT CONFIGURATION -----
strOldOrgUnit = "<OldOrgUnitDN>" ' e.g. ou=Domain Users,dc=xxx,dc=xxx
strNewOrgUnit = "<NewOrgUnitDN>" ' e.g. ou=XYZ,ou=Domain Users,dc=PharMerica,dc=net
' ------ END CONFIGURATION --------
set objOldOU = GetObject("LDAP://" & strOldOrgUnit)
set objNewOU = GetObject("LDAP://" & strNewOrgUnit)
for each objChildObject in objOldOU
Wscript.Echo " Moving " & objChildObject.Name
objNewOU.MoveHere objChildObject.ADsPath, objChildObject.Name
next

The goal is to find all user objects in the Domain Users OU and move them to the XYZ OU. I want it to ignore child OUs, so that the script will ONLY move any user objects it finds, nothing else (no OU's, no computer objects, etc.). When I run this script, it moves the user objects but it is also moving the child OUs. How can I stop it from doing that?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top