β¨ Quick Command β Multi-Server Message Tracking in Exchange Server SE / 2019
- On-Premises Exchange SE / 2019 / 2016: Enumerate all transport nodes with
Get-TransportServiceand pipe toGet-MessageTrackingLog. - Exchange Online (Microsoft 365):
Get-MessageTrackingLogis on-premises onlyβuseGet-MessageTraceV2in Exchange Online PowerShell v3.
In a multi-server Exchange Server Subscription Edition (SE), 2019, or 2016 organization, inbound and outbound messages can traverse any Mailbox/Transport server in your DAG or AD site. Running Get-MessageTrackingLog on one server at a time is slow and error-prone during an active mail-flow incident.
This updated PowerShell function (Search-ExchangeMessageTracking) automatically discovers all Exchange Transport servers via Get-TransportService (replacing the deprecated Exchange 2010 Get-TransportServer cmdlet), queries them in one pass, and returns unified chronological results.
Multi-Server Message Tracking Flow
PowerShell Function: Search-ExchangeMessageTracking
Save this script as Search-ExchangeMessageTracking.ps1 and dot-source it inside the Exchange Management Shell (. .\Search-ExchangeMessageTracking.ps1):
POWERSHELL
function Search-ExchangeMessageTracking {
<#
.SYNOPSIS
Queries Get-MessageTrackingLog across all Exchange Server SE/2019/2016 Transport services.
#>
[CmdletBinding()]
param(
[string]$Sender,
[string]$Recipient,
[string]$Subject,
[datetime]$Start = (Get-Date).AddDays(-2),
[datetime]$End = (Get-Date),
[string]$ExportCsvPath
)
$Params = @{
Start = $Start
End = $End
ResultSize = "Unlimited"
}
if ($Sender) { $Params.Sender = $Sender }
if ($Recipient) { $Params.Recipients = $Recipient }
if ($Subject) { $Params.MessageSubject = $Subject }
$Servers = Get-TransportService
Write-Host "[*] Querying $($Servers.Count) Exchange Transport server(s)..." -ForegroundColor Cyan
$Results = foreach ($Srv in $Servers) {
Get-MessageTrackingLog -Server $Srv.Name @Params |
Select-Object Timestamp, ServerHostname, EventId, Source, Sender,
@{ Name = "Recipients"; Expression = { $_.Recipients -join "; " } },
MessageSubject, ConnectorId, RecipientStatus
}
$Sorted = $Results | Sort-Object Timestamp
if ($ExportCsvPath) {
$Sorted | Export-Csv -Path $ExportCsvPath -NoTypeInformation -Encoding UTF8
Write-Host "[+] Exported $($Sorted.Count) tracking events to $ExportCsvPath" -ForegroundColor Green
}
return $Sorted
}
Usage Examples
1. Track by Sender and Recipient
POWERSHELL
Search-ExchangeMessageTracking -Sender "[email protected]" -Recipient "[email protected]" |
Format-Table Timestamp, ServerHostname, EventId, Source, RecipientStatus -AutoSize
2. Track by Subject Across the Last 7 Days and Export to CSV
POWERSHELL
Search-ExchangeMessageTracking `
-Subject "Quarterly Invoice" `
-Start (Get-Date).AddDays(-7) `
-ExportCsvPath "C:\Temp\MessageTracking.csv"
Related Mail Flow Guides
- Tracking mail in Microsoft 365 / Exchange Online? See our Exchange Online
Get-MessageTraceV2Guide. - Need a refresher on how the Transport Service routes messages? Read Exchange Server Mail Flow Architecture.
π¬ Reader Comments & Feedback
Did this runbook help, or did Microsoft change a cmdlet or UI menu? Share your feedback below.
Leave a Comment or Report an Update