How to Track Email in Exchange Online via PowerShell (Get-MessageTraceV2 & Extended Trace)

When a user reports that an expected email never arrived—or an outbound message bounced silently—Message Trace in Exchange Online is the fastest way to pinpoint where the message went.

Legacy Office 365 guides relied on Get-MessageTrace (which had a strict 10-day window and older pagination behavior). Today, Microsoft provides Get-MessageTraceV2 (up to 90 days of real-time queryable trace data in ExchangeOnlineManagement v3.7+) alongside Extended Message Trace (Start-HistoricalSearch) for deep routing, transport rule, and connector diagnostics.


Exchange Online Message Trace Workflow

Exchange Online PowerShell Message Tracking Workflow 1. Query Summary Trace Get-MessageTraceV2 • Filter by SenderAddress • Filter by RecipientAddress • Status: Delivered / Failed / Quarantined / FilteredAsSpam 2. Inspect Hop Events Get-MessageTraceDetailV2 • Shows Transport Rule hits • Shows NDR / 550 bounce text • Shows Spam/Quarantine reason 3. Deep / Extended Trace Start-HistoricalSearch • Full CSV with TLS, Connector, SPF/DKIM/DMARC & SCL • Retained up to 90 days Note on Get-MessageTrace vs. Get-MessageTraceV2: Always use Get-MessageTraceV2 in ExchangeOnlineManagement v3.7+ for faster REST queries and extended 90-day lookbacks.

Step 1: Connect to Exchange Online PowerShell

POWERSHELL
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline -ShowBanner:$false

Step 2: Track Emails Between a Sender and Recipient

Query the last 48 hours (or up to 90 days with Get-MessageTraceV2) and format the delivery status:

POWERSHELL
$StartDate = (Get-Date).AddDays(-7)
$EndDate   = Get-Date

$Messages = Get-MessageTraceV2 `
    -SenderAddress "[email protected]" `
    -RecipientAddress "[email protected]" `
    -StartDate $StartDate `
    -EndDate $EndDate

$Messages | Select-Object Received, SenderAddress, RecipientAddress, Subject, Status, FromIP, ToIP |
    Format-Table -AutoSize

Step 3: Inspect Detailed Delivery & Bounce Events

If a message shows Failed, Quarantined, or Pending, pipe its MessageTraceId and RecipientAddress into Get-MessageTraceDetailV2 to see the exact SMTP error or Transport Rule that acted on it:

POWERSHELL
foreach ($Msg in $Messages) {
    Write-Host "`n--- Trace Details for: $($Msg.Subject) ($($Msg.Status)) ---" -ForegroundColor Cyan
    Get-MessageTraceDetailV2 -MessageTraceId $Msg.MessageTraceId -RecipientAddress $Msg.RecipientAddress |
        Select-Object Date, Event, Action, Detail |
        Format-Table -Wrap -AutoSize
}

Step 4: Run an Extended Message Trace (Start-HistoricalSearch)

When you need full TLS cipher details, connector names, or SPF/DKIM/DMARC evaluation headers for an incident report, queue an asynchronous Extended Message Trace:

POWERSHELL
Start-HistoricalSearch `
    -ReportTitle "Incident-Trace-$(Get-Date -Format 'yyyyMMdd')" `
    -StartDate (Get-Date).AddDays(-14) `
    -EndDate (Get-Date) `
    -ReportType MessageTraceEx `
    -SenderAddress "[email protected]" `
    -NotifyAddress "[email protected]"

Check job progress with Get-HistoricalSearch and download the CSV directly from the Exchange Admin Center (Mail flow > Message trace > Downloadable reports).

💬 Reader Comments & Feedback

Did this runbook help, or did Microsoft change a cmdlet or UI menu? Share your feedback below.