Office365 – PowerShell to export a message flow trace with Get-MessageTrace

The following PowerShell snippet can be used to to export the results of a message trace, unfortunately at the time of writing the Office365 portal does not allow you to do this in the GUI.

Capture

Connecting to Office365 via Powershell

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

Exporting messages based on the sender address

Note the dates and in the American format mm/dd/yy

Get-MessageTrace -SenderAddress [email protected] -StartDate 03/31/2016 -EndDate 04/07/2016 | Export-Csv D:\messagetrace.csv

Exporting messages based on the recipient address

Note the dates and in the American format mm/dd/yy

Get-MessageTrace -RecipientAddress [email protected] -StartDate 03/31/2016 -EndDate 04/07/2016 | Export-Csv D:\messagetrace.csv

Leave a Comment

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