PowerShell Exchange message tracking commands

Note for office365: If you are tracking messages older that 7 days, then you'll have to use the GUI and wait as the job takes a while to access the log archives. (4 days it took to return the results when I last used it!! Useless!)

Here's the command for Office 365:
Get-MessageTrace -SenderAddress john@contoso.com -StartDate 06/13/2015 -EndDate 06/15/2015

Here's the powershell commands you'll need for doing some message tracking in Exchange.

-Get message tracking logs:

get-messagetrackinglog -Sender "" -Start "4/28/2015" -End "4/30/2015" | Select-Object Timestamp,ServerHostname,ClientHostname,Source,EventId,Recipients | Sort-Object -Property Timestamp

-Get failed emails:

Get-TransportServer | Get-MessageTrackingLog -ResultSize Unlimited | ? {$_.EventID -eq "DSN" -OR $_.EventID -eq "FAIL"} | Select *, {$_.Recipients} | Export-CSV D:\FailedEmails.csv -NoType

-Failed emails for today:

get-messagetrackinglog -Sender "" -Start "4/28/2015" -End "4/30/20
| Select-Object Timestamp,ServerHostname,ClientHostname,Source,EventId,Recipients | Sort-Object -Property Timestamp