Recipe 7.8. Removing a Routing GroupProblemYou need to remove a routing group in your Exchange organization. SolutionUsing a graphical user interface
Using VBScript' This code deletes a routing group if it meets several tests ' ------ SCRIPT CONFIGURATION ------ ' Name of the Exchange organization strExchangeOrg = "<Organization>" ' e.g., ExampleOrg ' Name of the administrative group the routing group is in strAdminGroup = "<AdminGroup>" ' e.g., SeattleAG ' Name of the routing group the server is in strRoutingGroup = "<RoutingGroup>" ' e.g., RedmondRG ' Default boolean state; do not change boolReady = 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 DiscussionDeleting a routing group is simpler than creating it, although you do need to ensure that you have moved all member servers to other routing groups. You will not be able to move a server from routing group if it hosts any connectors to or from that routing group. Scripting this task is not documented but is a simple application of basic ADSI scripting methods. There is a caveat: because it uses the DeleteObject(0) method, which recursively deletes the object and any objects it contains, you need to first verify two items of information:
The scripted solution performs these checks for you to ensure that deleting the routing group object will not cause problems. Since this is a two-part test, we use a simple Boolean variable and set it to False if we fail a test. Testing for member servers is relatively easy: we merely need to check for the existence of the msExchRoutingGroupMembersBL property on the routing group object. This property is a backlink to the msExchHomeRoutingGroup properties on the server objects. Active Directory maintains the backlinks automatically; when all the servers are moved out of the routing group, the backlink property is removed from the routing group object. We use the GetInfo method to pull the object's attributes into the local cache, then iterate through them with the Item method to check the current attribute's Name property. If we find a match, we have failed the test. The second test is just as simple, although this time we merely need to check to see if the Connections container in the routing group object is empty or not. We do this with a simple For Each loop; if the loop runs at all, it means we have one or more objects in the container. We print out the names of the objects and set the Boolean variable to False. See AlsoRecipe 7.7 for creating routing groups, Recipe 7.9 for setting the RGM, Recipe 7.10 for moving server between routing groups, Recipe 5.5 Deleting an OU" of Active Directory Cookbook (O'Reilly), and Chapter 5, "Configuring Your Routing Topology," of the Exchange Server 2003 Transport and Routing Guide:
|