Skip to Content

Solved: How do I execute message trace in Office 365 based on the subject line?

Question

How do I run a message trace in Microsoft Office 365 to search by subject line?

Solved: How do I execute a message trace in Office 365 based on the subject line?

Solution

Try this to find all messages with a particular subject in the last 24 hours:

$dateEnd = get-date
$dateStart = $dateEnd.AddHours(-24)

$count = Get-MessageTrace -StartDate $dateStart -EndDate $dateEnd | Where {$_.Subject -eq "Phishing attempt"}
$count.Count

or

$dateEnd = get-date
$dateStart = $dateEnd.AddHours(-24)

$count = Get-MessageTrace -StartDate $dateStart -EndDate $dateEnd | Where {$_.Subject -eq "Phishing attempt"}
$count.Count

In my test tenant, my subject searching using this syntax is currently working. Also try to filter on different subjects that are present to see if the problem appears for all subject searching.

If you’re trying to search for a subject %LIKE% then use -match instead of -eq.

Reference

    Ads Blocker Image Powered by Code Help Pro

    Your Support Matters...

    We run an independent site that\'s committed to delivering valuable content, but it comes with its challenges. Many of our readers use ad blockers, causing our advertising revenue to decline. Unlike some websites, we haven\'t implemented paywalls to restrict access. Your support can make a significant difference. If you find this website useful and choose to support us, it would greatly secure our future. We appreciate your help. If you\'re currently using an ad blocker, please consider disabling it for our site. Thank you for your understanding and support.