Skip to Content
Active Directory Cookbook
book

Active Directory Cookbook

by Robbie Allen
September 2003
Intermediate to advanced
624 pages
15h 49m
English
O'Reilly Media, Inc.
Content preview from Active Directory Cookbook

5.6. Moving the Objects in an OU to a Different OU

Problem

You want to move some or all of the objects in an OU to a different OU. You may need to do this as part of a domain restructuring effort.

Solution

Using a graphical user interface

  1. Open the Active Directory Users and Computers snap-in.

  2. If you need to change domains, right-click on “Active Directory Users and Computers” in the left pane, select Connect to Domain, enter the domain name, and click OK.

  3. In the left pane, browse to the OU that contains the objects you want to move and click on it.

  4. Highlight the objects in the right pane you want to move, right-click on them, and select “Move.”

  5. Browse to the parent container you want to move the objects to, click on it.

  6. Click OK.

  7. Press F5 to refresh the contents of the OU. If objects still exist, repeat the previous three steps.

Using a command-line interface

> for /F "usebackq delims=""" %i in (`dsquery * "<OldOrgUnitDN>" -scope onelevel`)[RETURN] 
do dsmove -newparent "<NewOrgUnitDN>" %i

Using VBScript

' This code moves objects from the "old" OU to the "new" OU
' ------ SCRIPT CONFIGURATION ------
strOldOrgUnit = "<OldOrgUnitDN>" ' e.g. ou=Eng Tools,dc=rallencorp,dc=com
strNewOrgUnit = "<NewOrgUnitDN>" ' e.g. ou=Tools,dc=rallencorp,dc=com ' ------ 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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Active Directory Administration Cookbook

Active Directory Administration Cookbook

Sander Berkouwer
Active Directory Cookbook, 3rd Edition

Active Directory Cookbook, 3rd Edition

Laura E. Hunter, Robbie Allen
Active Directory Cookbook, 4th Edition

Active Directory Cookbook, 4th Edition

Brian Svidergol, Robbie Allen

Publisher Resources

ISBN: 0596004648Supplemental ContentCatalog PageErrata