Determine which domain controllers Exchange is using (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 queries the list of DSAccess instances and reports which
' DCs DSAccess is using.
' ------ SCRIPT CONFIGURATION ------
strServer = "<ServerFQDN>"  ' e.g. xch01.foobar.com; the NetBIOS name works too
' ------ 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 display their properties
Set listDCInst = objWMIExch.InstancesOf("Exchange_DSAccessDC")
strDCInfo = ""
For each objDCInst in listDCInst
   strDCInfo = strDCInfo & "DC: " & objDCInst.Name & " ("
   Select Case objDCInst.Type
     Case 0 strDCInfo = strDCInfo & "Configuration DC)"
     Case 1 strDCInfo = strDCInfo & "Domain Controller)"
     Case 2 strDCInfo = strDCInfo & "Global Catalog)"
   End Select
   Select Case objDCInst.ConfigurationType
     Case 0 strDCInfo = strDCInfo & " is manually configured."
     Case 1 strDCInfo = strDCInfo & " was auto-discovered."
   End Select
   strDCInfo = strDCInfo & VbCrLF
Next
   Wscript.Echo strDCInfo

This code has been viewed 1247 times.

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