[ Team LiB ] |
Recipe 5.4 Deleting the Objects in an OU5.4.1 ProblemYou want to delete all the objects in an OU, but not the OU itself. 5.4.2 Solution5.4.2.1 Using a graphical user interface
5.4.2.2 Using a command-line interfaceTo delete all objects within an OU, but not the OU itself, you need to use the -subtree and -exclude options with the dsrm command. > dsrm "<OrgUnitDN>" -subtree -exclude 5.4.2.3 Using VBScript' This code deletes the objects in an OU, but not the OU itself set objOU = GetObject("LDAP://<OrgUnitDN>") for each objChildObject in objOU Wscript.Echo "Deleting " & objChildObject.Name objChildObject.DeleteObject(0) next 5.4.3 DiscussionIf you want to delete the objects in an OU and recreate the OU, you can either delete the OU itself, which will delete all child objects, or you could just delete the child objects. The benefits to the later approach is that you do not need to reconfigure the ACL on the OU or relink GPOs. 5.4.4 See AlsoRecipe 5.3 for enumerating objects in an OU, Recipe 5.5 for deleting an OU, and MSDN: IADsDeleteOps::DeleteObject |
[ Team LiB ] |