33.5 C
Dubai
Monday, July 15, 2024

How to Clean up emails using keywords in Exchange Server

I got a request recently. Due to audit purposes, they gave me like 100 keywords and delete those emails where ever they are in the server.

Exchange 2010/2013/2016 and Office365 is much powerful and easy to do such tasks. We can use the discovery search feature to accomplish it.

Click the below Link – Make sure the Admin has appropriate Permissions

https://www.azure365pro.com/deleting-a-specific-email-from-entire-organization-in-exchange-2010-2/

$search = '"expenses" OR "credit" OR "tax audit" OR "Payment"'

Saved the 100 Keywords to $search in the above format.

To move Content to a Specific Mailbox –

This example searches all mailboxes in your organization for messages that contain the words  in $search . The search results are copied to the administrator Mailbox in the folder Exportedmailbox

Get-Mailbox "EntermailboxName" | Search-Mailbox -SearchQuery $search -TargetMailbox "administrator" -TargetFolder "ExportedMailbox" -LogLevel Full

To Delete Content

For Specific mailbox

Get-Mailbox "EntermailboxName" | Search-Mailbox -SearchQuery $search –DeleteContent

For All mailbox

Get-Mailbox  | Search-Mailbox -SearchQuery $search –DeleteContent

To Estimate how much mails you are going to delete (Logonly Switch)

Get-Mailbox "EntermailboxName" | Search-Mailbox -SearchQuery $search -TargetMailbox "administrator" -TargetFolder "ExportedMailbox" –LogLevel Logonly

Add on –
Deleting a Subject from all mailboxes – But  Excluding a Specific Sender (Logonly Switch)

Get-mailbox -Resultsize Unlimited | search-mailbox -searchquery {Subject:"Welcome to dubai" NOT from:"administrator"} -Logonly -Targetmailbox administrator -Targetfolder Inbox

Clearing Dumpster of a Specific Mailbox – (Clearing DeletedItemsSize to 0)

search-mailbox MAILBOXNAME -SearchDumpsterOnly -DeleteContent

 

Satheshwaran Manoharan
Satheshwaran Manoharanhttps://www.azure365pro.com
Award-winning Technology Leader with a wealth of experience running large teams and diversified industry exposure in cloud computing. From shipping lines to rolling stocks.In-depth expertise in driving cloud adoption strategies and modernizing systems to cloud native. Specialized in Microsoft Cloud, DevOps, and Microsoft 365 Stack and conducted numerous successful projects worldwide. Also, Acting as a Technical Advisor for various start-ups.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

× How can I help you?