' 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 enumerates the SMTP links and queues on an ' Exchange Virtual Server and only works on Exchange Server 2003. ' ------ SCRIPT CONFIGURATION ----- ' host name of the Exchange server strHostname = "" ' e.g., red-exch02 ' The number of the SMTP virtual server instance strVSInstance = ""' e.g., 1 for the default SMTP virtual server ' ------ END CONFIGURATION -------- ' Get the Exchange Namespace WMI object Set objWMIExch = GetObject("winmgmts://./root/MicrosoftExchangeV2") ' Get the list of Exchange_SMTPLink instances from the default virtual server ' and iterate through them. Set objLinksList = objWMIExch.ExecQuery ("Select * from Exchange_SMTPLink" &_ " Where VirtualMachine='" & strHostname &_ "' And VirtualServerName='" & strVSInstance & "'") For each objLinkInst in objLinksList strLinkInfo = strLinkInfo & "Link Name: " &_ objLinkInst.LinkName & VbCrLF & " Link ID: " &_ objLinkInst.LinkID & VbCrLF ' Now, get the associated Exchange_SMTPQueue instances and iterate through ' them. Set objQueuesList = objWMIExch.ExecQuery ("Select * from Exchange_SMTPQueue" &_ " Where VirtualMachine='" & strHostname &_ "' And VirtualServerName='" & strVSInstance &_ "' And LinkID='" & objLinkInst.LinkID &_ "' And LinkName='" & objLinkInst.LinkName & "'" ) For each objQueueInst in objQueuesList strLinkInfo = strLinkInfo & " Queue Name: " &_ objQueueInst.QueueName & VbCrLF & " Queue ID: " &_ objQueueInst.QueueID & VbCrLF Next strLinkInfo = strLinkInfo & VbCrLF Next Wscript.Echo strLinkInfo