Tuesday, June 4, 2013

How to Delete Mail from Multiple Mailboxes

How to Delete Mail from Multiple Mailboxes
 
Issue:

I had this recently where a spam email had went around.  I needed to find a way to delete the email from every mailbox. This can be done from Powershell command:
 
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 the following powershell cmdlet:
 
get-mailbox -result unlimited -Server YourServername | Search-Mailbox -SearchQuery 'Subject:"Your XYZ order"', 'from:"mailto:sender@xyz.com%22', 'body:"your body text"' -TargetMailbox hltest -TargetFolder "xyzspam"  -LogLevel full -DeleteContent >C:\deletedxyz10.txt
 
Where  YourServername is your mailbox server and "Your XYZ order" is the subject content, from, and body, you can search for one of them, or combination of two or three
 
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 -server "yourservername"| add-mailboxpermission -user administrator -AccessRights FullAccess
That command will give the correct rights to the administrator account.
 
With above commands you will be able to remove email from multiple mailboxes in Exchange 2010 and Exchange 2013.

No comments:

Post a Comment