TABLE OF CONTENTS
Introduction
This Article will help you be able to Delete mass emails from multiple inboxes through Terminal just by searching for the subject of the email.
Guide
you will need to open Terminal / PowerShell while connected to the Exchange online.
When you have signed in run the following command
New-ComplianceSearch -name "" -ExchangeLocation -ContentMatchQuery 'subject:""'
in the name part of the code you will need to put the name of the search for example Birth Certfictae Request 2
Then in Exchange locations you will need to put the email or emails of all the inboxes you will want to be searched through
then for content match query we will be searching for the subject.
here is an example
New-ComplianceSearch -name "Birth Certificate Request2" -ExchangeLocation [email protected],[email protected],[email protected],[email protected] -ContentMatchQuery 'subject:"Fw: birth certificate"'
after this has ran you will need to run the following
Start-ComplianceSearch “Birth Certificate Request2”
One this has been ran you will need to go to the content search under compliance on office 365 admin
Content search - Microsoft Purview
from here go down to the bottom for the latest search which has been created
click on this search and look for the status to see how long it will take and to see when this is completed.
from here you can then delete the emails that have been found in the search,
You will need to run the purge script which will delete these emails
New-ComplianceSearchAction -SearchName “Birth Certificate Request2” -purge -purgetype HardDelete
then this will begin the deletion process of these email.