List all connectors in Exchange (Perl)

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 Perl code from this site.

# This script was adapted from a VBScript 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 connectors in the Exchange organization.

# ------ SCRIPT CONFIGURATION ------

use Win32::OLE qw(in);

$strComputerName = '<serverName>';
# e.g. "batman.robichaux.net"

# ------ END CONFIGURATION ---------
$strWMIQuery = 'winmgmts://' . $strComputerName . '/root/cimv2/applications/exchange';

$connectorList = Win32::OLE->GetObject('ExchangeConnectorState');
foreach my $ExchangeConnector (in $connectorList) {
    print 'Name:             ' . $ExchangeConnector->Name, "\n";
    print 'DN:               ' . $ExchangeConnector->DN, "\n";
    print 'Routing Group DN: ' . $ExchangeConnector->GroupDN, "\n";
    if (($ExchangeConnector->IsUp)) {
        print "Status:          : Up\n";
    }
    else {
        print "Status:          : Down\n";
    }
}

This code has been viewed 1083 times.

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