Exchange 2007 / 2010 Search for and Delete Emails Containing “yoursearchtext”

KB ID 0000343

Problem

You have a nasty email that contains a virus or some offensive content and you want to delete ALL instances of it.

Solution

1. Log on as the domain administrator > Open the Exchange Command Shell.

2. First grant the correct rights to the administrator account.

This gives the Administrator FULL rights to ALL mailbox’s

Get-mailbox -Database “Mailbox Database”| add-mailboxpermission -user administrator -AccessRights FullAccess

Note: this assumes your mailbox database is called “Mailbox Database”.

3. Then locate and delete the emails containing “yoursearchtext”.

Get-Mailbox -Database “Mailbox Database” | Export-Mailbox -SubjectKeywords “yoursearchtext” -DeleteContent

Note: If you are unable to use the export-mailbox command then see here

Related Articles, References, Credits, or External Links

NA

Author: Migrated

Share This Post On