Create Routing Group (VBScript)

This code can be found in Chapter 7 of Exchange Server Cookbook

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

' 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 creates a Routing Group in an Exchange administrative group.

' ------ SCRIPT CONFIGURATION -----
' The common name of the Exchange server object to be made RGM
strExchangeServer = "<ExchangeServerName>" ' e.g., red-exch02
' Name of the administrative group the routing group will be in
strAdminGroup = "<SourceAG>" ' e.g., SeattleAG
' Name of the new routing group to create
strRoutingGroup = "<TargetRG>" ' e.g., RedmondRG
' Name of the Exchange organization
strExchangeOrg = "<ExchangeOrg>" ' e.g., ExampleOrg
' ------ END CONFIGURATION --------

strConfigDN = GetObject("LDAP://RootDSE").Get("configurationNamingContext")
' The path of the routing group container
strRGContainerDN = "LDAP://CN=Routing Groups,CN=" & strAdminGroup &_
   ",CN=Administrative Groups,CN=" & strExchangeOrg &_
   ",CN=Microsoft Exchange,CN=Services," & strConfigDN
' The path of the new routing group
strRoutingGroupDN = "LDAP://CN=" & strRoutingGroup &_
   ",CN=Routing Groups,CN=" & strAdminGroup &_
   ",CN=Administrative Groups,CN=" & strExchangeOrg &_
   ",CN=Microsoft Exchange,CN=Services," & strConfigDN
' Create the routing group
Set objRGContainer = GetObject(strRGContainerDN)
Set objRoutingGroup = objRGContainer.Create("msExchRoutingGroup", "CN=" &_
   strRoutingGroup)
' Create the Connectors container in the new routing group
Set objConnectionsContainer = objRoutingGroup.Create("msExchConnectors", _
   "CN=Connections")
objConnectionsContainer.Put "adminDisplayName", "Connections"
objConnectionsContainer.SetInfo
Wscript.Echo "Created routing group: " & strRoutingGroup & VbCrLF

This code has been viewed 1122 times.

New from the creators of TechTasks.com: StatSheet.com