Wednesday, March 27, 2013

Delete Mail from Multiple Mailboxes (2k7\2k10)


Delete Mail from Multiple Mailboxes


IT Problem

I had this recently where an email had went around a school and was quite sensitive, I needed to find a way ofdeleting the email from every mailbox…and fast. Luckily this can be done in power shell So if you need todelete an email in powershell across the organization quickly follow the guide below.

Note the new section at the bottom of this article for deleting emails in exchange 2010 SP1

IT Solution

This can be done with power shell. See the command below.
NOTICE out of the box these commands are not enabled, you will need to see this article first if you have not already enabled them – Enable Export Mailbox Commands In Exchange 2010
Once the above is done you can now proceed
Get-Mailbox -Database mailboxdb | Export-Mailbox -SubjectKeywords "Virus message" -DeleteContent
Where  MailboxDB is your store and “Virus Message” is the content
You  will need to use an account that has the correct permissions to give the correct permissions to the user use this command
get-mailbox -Database "Mailbox Database"| add-mailboxpermission -user administrator -AccessRights FullAccess
That command will give the correct rights to the administrator account.



Delete Email From Exchange 2010 SP1

Microsoft changed a few commands for SP1  of exchange 2010.
In Exchange 2010 SP1, we use the  New-MailboxExportRequest and the New-MailboxImportRequest to exportimport emails. You also use this in conjunction with the  Search-Mailbox command and add the add parameter -DeleteContent.
For example,
Get-Mailbox -Server  "your server" | Search-Mailbox -SearchQuery 'Subject:"pictures of your mum"' -DeleteContent

No comments:

Post a Comment