Wednesday, October 2, 2013

Deleting a specific mail from an entire Exchange 2010 organisation


Below is a quick guide to deleting a specific mail from an entire Exchange 2010 organisation:


 

Grant access to run commands required:
Add-RoleGroupMember -Identity "Mailbox Import-Export" -Member "Gareth.Cuff"
Create a copy of all mails to be deleted into Gareth.Cuff Mailbox
get-mailbox | Search-Mailbox -SearchQuery 'subject:"Absence from Office" and from:"The Dude"' -TargetMailbox "Gareth.Cuff" -TargetFolder "SearchResult" -LogLevel Full
Export to PST to save as Emails in mailbox will be deleted by next –deletecontent command
Delete the Mails
Get-Mailbox | Search-Mailbox -SearchQuery 'subject:"Absence from Office" and from:"Tony Stephens"' -DeleteContent