' This script was originally published in the Exchange Cookbook, ' (http://www.exchangebookcook.com). Written by Paul Robichaux, ' Missy Koslosky, and Devin Ganger. Redistributed with permission ' of the publisher, O'Reilly & Associates. ' This code deletes a routing group if it meets several tests ' ------ SCRIPT CONFIGURATION ----- ' Name of the Exchange organization strExchangeOrg = "" ' e.g., ExampleOrg ' Name of the administrative group the routing group is in strAdminGroup = "" ' e.g., SeattleAG ' Name of the routing group the server is in strRoutingGroup = "" ' e.g., RedmondRG ' Default boolean state; do not change bool Ready = True ' ------ END CONFIGURATION -------- ' Create the routing group object strConfigDN = GetObject("LDAP://RootDSE").Get("configurationNamingContext") strRoutingGroupDN = strRoutingGroup & ",CN=Routing Groups,CN=" & _ strAdminGroup & ",CN=Administrative Groups,CN=" & _ strExchangeOrg & ",CN=Microsoft Exchange,CN=Services," & _ strConfigDN Set objRoutingGroup = GetObject("LDAP://CN=" & strRoutingGroupDN) ' Test for member servers still in the RG; set boolean false if found objRoutingGroup.GetInfo numProperties = objRoutingGroup.PropertyCount For PropCount = 0 To (numProperties-1) Set propEntry = objRoutingGroup.Item(PropCount) If (propEntry.Name = "msExchRoutingGroupMembersBL") Then Wscript.Echo "Member servers found in routing group " &_ strRoutingGroup & ";" Wscript.Echo " See Recipe 7.10 to move servers to a new RG." boolReady = False End If Next ' Test for connectors still in the RG; set boolean false if found strConnectorsDN = "Connections,CN=" & strRoutingGroupDN Set objConnectors = GetObject("LDAP://CN=" & strConnectorsDN) For Each objConnection in objConnectors Wscript.Echo "Connector found: " & objConnection.Name boolReady = False Next ' If the boolean is still true, it's safe to delete the RG If boolReady = True Then objRoutingGroup.DeleteObject(0) Wscript.Echo "Deleted RG " & strRoutingGroup & "." & VbCrLF Else Wscript.Echo "RG " & strRoutingGroup & " not deleted." & VbCrLF End If