deleting email from inbox

Modified on Tue, 14 Mar, 2023 at 11:04 AM


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.




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article