Force Exchange to run the topology discovery process (VBScript)

This code can be found in Chapter 3 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 removes all existing instances of the Exchange_DSAccessDC object.
' Doing so forces Exchange to re-run the topology discovery process. 
' ------ SCRIPT CONFIGURATION ------
strServer = "batman" '' "<ServerFQDN>"  ' e.g. xch01.foobar.com
strDC = "batman" '' "<DomainControllerFQDN>" ' e.g. dc01.foobar.com
configType = 0 		' 0 = manual; 1 = automatic
' ------ END CONFIGURATION ---------


' Get the Exchange Namespace WMI object
Set objWMIExch =  GetObject("winmgmts:{impersonationLevel=impersonate}!//" &_
  strServer & "/root/MicrosoftExchangeV2")

' Get the list of Exchange_DSAccessDC instances and iterate through them
' to modify their properties; all instances of this Type will become manually
' configured.
Set listDCInst = objWMIExch.InstancesOf("Exchange_DSAccessDC")
For each objDCInst in listDCInst
   objDCInst.Type = configType
   objDCInst.Put_
Next

' Delete all manually configured instances of one Type so that the discovery
' state is reset to Automatic and triggers topology discovery
For each objDCInst in listDCInst
   If (objDCInst.ConfigurationType = configType) Then 
      wScript.echo "    **Deleting manually configured DC."
      objDCInst.Delete_
   End if
Next

This code has been viewed 994 times.

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