List Exchange servers (VBScript)

This code can be found in Chapter 2 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 uses WMI to interrogate the Exchange routing table 
' and list all known Exchange servers.
' ------ SCRIPT CONFIGURATION ------
 strComputerName = "batman"	' e.g. "batman.robichaux.net"
   
' ------ END CONFIGURATION ---------
  strE2KWMIQuery = "winmgmts://" & strComputerName &_
   "/root/cimv2/applications/exchange"
  strE2K3WMIQuery = "winmgmts://" & strComputerName &_
    "/root/MicrosoftExchangeV2"
  

' display basic attributes using Exchange 2000 WMI provider 
  set serverList = GetObject(strE2KWMIQuery).InstancesOf("ExchangeServerState")
  WScript.Echo "Exchange 2000/Exchange Server 2003 properties"
  for each ExchangeServer in serverList
    WScript.Echo "  Name:    " & ExchangeServer.Name
    WScript.Echo "  DN:      " & ExchangeServer.GroupDN
    WScript.Echo "  Version: " & ExchangeServer.Version
  Next
  WScript.Echo ""
  
  ' display additional Exchange 2003 provider information
  Set serverList = GetObject(strE2K3WMIQuery).InstancesOf("Exchange_Server")
  WScript.Echo "Exchange Server 2003 properties"  
  For each Exchange_Server in serverList
  	WScript.Echo "Exchange 2003 properties--------"
 	WScript.Echo "  Name:        " & Exchange_Server.Name
 	WScript.Echo "  FQDN:        " & Exchange_Server.FQDN
 	WScript.Echo "  Admin Group  " & Exchange_Server.AdministrativeGroup
  Next

This code has been viewed 3156 times.

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