Deleting a Site
You want to delete a site.
Using a graphical user interface
Using a command-line interface
> dsrm <SiteDN> -subtree -noprompt
Alternately, you can remove a site and its associated objects by issuing the following AdMod command:
> admod -b "cn=<SiteName>,cn=sites,cn=configuration,<ForestRootDN>" del -treedelete
' This code deletes a site and all child containers. ' ------ SCRIPT CONFIGURATION ------ strSiteName = "<SiteName>" ' e.g. Dallas ' ------ END CONFIGURATION -------- set objRootDSE = GetObject("LDAP://RootDSE") set objSite = GetObject("LDAP://cn=" & strSiteName & ",cn=sites," & _ objRootDSE.Get("configurationNamingContext") ) objSite.DeleteObject(0) WScript.Echo "Successfully deleted site " & strSiteName
When deleting a site, be very careful to ensure that no active server objects exist within it. If you delete a site that contains domain controllers, it will disrupt replication for all domain controllers in that site. A more robust VBScript solution would be to first perform an ADO query for all server objects using the distinguished name of the site as the base DN. If no servers were returned, then you could safely delete the site. If server objects were found, you should move them before deleting the site.
It is also worth noting that deleting a site does not delete any of the subnets or site links that are associated with the site. This would be another good thing to add to the VBScript solution. That is, before you delete the site, delete any subnets and site links that are associated with the site or, more likely, associate them with a different site.
Recipe 12.1 for more on creating a site and Recipe 12.7 for creating a subnet