Wednesday, 30 September 2015

Collect exchange message tracking logs from multiple servers

It's a common scenario where an email didn't get to the recipient but there are many Exchange servers that could have been involved in the transport of the email. If you need to collect logs from all these Exchange servers then I've written a useful script.

This script will get all Exchange 2007/2010 Hub Transport and Exchange 2013 Mailbox servers in your organization and collect the logs. From there you can troubleshoot the message delivery.

$Start = "09/28/2015"
    $End = "09/29/2015"
    $HTServers = @()
    Get-ExchangeServer | ? { `
    ($_.AdminDisplayVersion.Major -eq "15" -and $_.ServerRole -match "Mailbox") -or `
    ($_.AdminDisplayVersion.Major -eq "8" -and $_.ServerRole -match "HubTransport") -or `
    ($_.AdminDisplayVersion.Major -eq "14" -and $_.ServerRole -match "HubTransport") `
    } | % {$HTServers += $_.Name}

    $emails = @()
    foreach($HTServer in $HTServers)
        {
            $emails += Get-MessageTrackingLog -Start $Start -End $End -ResultSize Unlimited -Server $HTServer
        }

The $emails array now includes message tracking logs from all Exchange servers which you can use for troubleshooting. See below:




Here we can see the issues delivering email on one of my test servers where it ran out of resources. 

No comments:

Post a Comment