Powershell: Counting messages processed by a Receive Connector

By | October 11, 2012

Recently I was doing some testing with a new Exchange 2010 Receive Connector and wanted a method to check how many messages it was processing.  I came up with the following Powershell snippet that seems to work well.

$i = 0
do {
    $now = get-date
    (Get-MessageTrackingLog -ResultSize unlimited -Start "11/10/2012 3:00PM" -End $now -Server MYSERVER `
    | ? {$_.connectorid -eq "MYSERVER\SMTP Relay"}).count
    sleep 30
    $i = $i + 1
until ($i -eq 100) 

The script uses the “do until” method to query the message tracking logs on a specific server at 30 second intervals for instances of the Receive Connector and displays the count.  It does this a hundred times (or until you stop the script).

2 thoughts on “Powershell: Counting messages processed by a Receive Connector

  1. jkavanagh58

    Nice, but why not clean up $i = $i 1 to just read $i
    but both methods work

  2. jkavanagh58

    It appears the plus signs were stripped from my comment. “$i ” versus “$i = $i 1”
    placed quotes around it hoping it won’t get stripped out this time.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.