Showing posts with label Search-Mailbox. Show all posts
Showing posts with label Search-Mailbox. Show all posts

Friday, June 10, 2011

Delete emails in multiple mailboxes in Exchange 2010 SP1

Export-Mailbox is no longer supported in Exchange 2010 sp1, in stead there is New-MailboxExportRequest but the problem is that “-DeleteContents” is not supported with mailbox export.

In order to be able to search and delete emails from multiple Exchange 2010 mailboxes one has to have the following roles assigned.

New-ManagementRoleAssignment -Role "Support Diagnostics" –User username

New- ManagementRoleAssignment -Role "Mailbox Import Export" -User username

above will ensure that a user has proper permissions to perform this command.

In order to find and delete a certain email from one mailbox you can perform the following command

Search-Mailbox -Identity username -SearchQuery 'subject:"Email Subject that you want to search for"' –DeleteContent

this can be run for all mailboxes on a server as well

Get-Mailbox –Server “*servername*” –ResultSize unlimited | Search-Mailbox -SearchQuery 'subject:"Email Subject that you want to search for"' –DeleteContent