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?
' 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?