17.26. Listing Domain Controllers and Global Catalog Servers Used by an Exchange Server

Problem

You want to list the domain controllers and global catalog servers currently being used by an Exchange Server.

Solution

Using a graphical user interface

  1. Open the Exchange System Manager (ESM) snap-in.

  2. In the left pane, browse to the Servers container.

  3. Right-click on the target server and select Properties.

  4. Click on the Directory Access tab and view the domain controllers being used.

Using VBScript

' This code enumerates domain controllers being used.
' ------ SCRIPT CONFIGURATION ------
strComputer = "<Exchange Server>" 'e.g., ExchServer2
' ------ END CONFIGURATION ---------
   
set objWMI = GetObject("winmgmts:\\" & strComputer & _
                       "\root\MicrosoftExchangeV2")
   
set objDCList = objWMI.ExecQuery("Select * from Exchange_DSAccessDC",,48)
for each objDc in objDCList
  Wscript.Echo "DCName: objDc.name"
  strTemp = "Automatic"
  if (dc.ConfigurationType=0) then strTemp="Manual" 
  Wscript.Echo "  Selection: " & strTemp
  Wscript.Echo "  Is Fast  : " & objDc.IsFast
  Wscript.Echo "  In Sync  : " & objDc.IsInSync
  Wscript.Echo "  Is Up    : " & objDc.IsUp
  Wscript.Echo "  Ldap Port: " & objDc.LDAPPort
  strTemp = "Global Catalog"
  if (objDc.type=0) then strTemp = "Config"
  if (objDc.type=1) then strTemp = "Local Domain"
  Wscript.Echo "  Role     : " & strTemp
  Wscript.Echo "-----------"
Next
Wscript.Echo "Script completed successfully."

Discussion

Exchange is very dependent upon Active Directory domain controllers. The list of domain controllers ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.