Removing emails from all mailboxes with certain text in subject

So, we had an errant program kick off about 15,000 emails to our users. I have our spam filters now blocking these on the edge until that gets resolved, but now I would like to clean our our users' mailboxes for them. Is there anyway with Exchange 2007 to remove all emails with certain text in the subject line? It would need to be a partial match because the subject changes slightly for each email.

I am trying to do this with Forefront's manual scan job + content filter, but it does not seem to like partial matches on the subject.


Solution 1:

I haven't used it myself, but the export-mailbox PowerShell command should be what you need using the -Deletecontent option along with the -SubjectKeywords option. Here's the link from MSDN on export-mailbox. I also found this blog post with some good information.

Sample:

Get-Mailbox | Export-Mailbox -SubjectKeywords “Text to block” -Deletecontent -confirm:$false -whatif (omit -whatif to actually run the command.)

Solution 2:

use the powershell commands, I don't have a exchange 2007 server I can test this on but I've done this in the past I'll hunt around for the correct scriptlet. tr