Updated – Supports Exchange 2010/2013/2016 and Office365
There are many scenarios where we need to get rid of some Emails from the whole server
1. Virus
2.Confidential Email sent wrongly – Got to remove it
3. Need to remove a Email with Specific subject from all the mailboxes
Exchange 2010 has Good features on Searching it and Remove it .
So Will Learn how to do that.
For a User to Execute this commands , he needs specific permissions like he should be a member of Discovery Management role and he should be member of Mailbox Import Export
By Default, Administrator is not a member these roles
Use Exchange Management Shell
Replace the User Name with the Person whom you want to give access to Search and delete
Add-RoleGroupMember "Discovery Management" -Member "User Name"
or
You can use GUI or Shell, Adding the Discovery Management Role via GUI is much easier.
Login with the Exchange Control Panel URL below –
Login with Admin Credentials –
Double Click on Discovery Management and Add Administrator as a member of Discovery Management and Save it
===============
To Add a User in Mailbox Import Export Role – Run in Exchange Management Shell
New-Managementroleassignment –Role "Mailbox Import Export" –User "Administrator"
===========
Close and Reopen the Exchange Mangement Shell – so that the new commands will start working
===========
Now Before Deleting in Bulk , We can use a log only switch to verify how many Mails we are going to delete
and to verify the we are going to delete the right one
Get-mailbox | search-mailbox –searchquery "Subject:'virus'" –Logonly –Targetmailbox administrator –Targetfolder Inbox
Now this will show how many mailboxes have this content
A mail will be generated to Administrators inbox with Item Count As shown below —
=======
Now we will go ahead and delete it
Get-mailbox | search-mailbox –searchquery "Subject:'virus'" –DeleteContent
Before — From All the Mailboxes
Now its gone from All the mailboxes
Reference link –
http://technet.microsoft.com/en-us/library/dd298173.aspx
Hope it helped you to understand better !!
If you feel its too confusing – Â Check out the Automated Script to do these tasks for you
Discovery Search Simplified Script to Delete a Specific Email and other Tasks – Exchange 2010
Howdy just wanted to give you a quick heads up. The words in your content seem to be running off the screen in Ie. I’m not sure if this is a format issue or something to do with browser compatibility but I thought I’d post to let you know. The design and style look great though! Hope you get the issue solved soon. Thanks
Thanks for your post. I would like to ask you that if the subject was written in unicode format. I coudn’t for sure copy the subject in Arabic format to Exchange-Shell it well show “??????”. how can I solve this issue.
You should try different parameters . From address. date / time
I need help, I have exchange 2010 SP3. I want to remove all emails from all the mailboxes send by a particular recipient in our organization. All correspondence “from and to” to this recipient must be removed, please help me how to do it.
just write a simple syntax from:a@domain.com To:b@domain.com “Subject:’*'” . it should work
gud
Thank you
This worked great to get rid of the messages. Should I now removed those accounts from the Mailbox Import Export and Discovery groups/roles?
Yes, You can remove them if you wish . Not that mailbox has access to all the mailboxes in your environment.
i have one question, i want to search and delete all message from one mailbox (example: apc@domain.com) sent to all mailbox (*@domain.com). Please help me how to do it. Thanks.
AWESOME! Absolute champion post!
Thank you
I don’t even know the way I ended up here, however I assumed this submit used to be good.
I do not realize who you are however certainly you’re
going to a well-known blogger in case you are not already.
Cheers!
Here is the search syntax documentation: https://msdn.microsoft.com/en-us/library/ee693615(v=exchg.140).aspx
If you add | where-object {$_.ResultItemsCount -ne 0} to the search and delete PowerShell commands, you’ll just see the mailboxes where the content was found, instead of the entire list of them.
For example:
Get-mailbox | search-mailbox –searchquery “Subject:’virus'” –Logonly –Targetmailbox administrator –Targetfolder Inbox | where-object {$_.ResultItemsCount -ne 0}
Great article.
I have created an user and user is member of “Discovery management group” and mailbox import and export
and yet when I am trying to delete any specific mail. I am getting error as mentioned below.
“The target mailbox or .pst file path is required”
can any one help in this issue
I have created an user in my exchange 2010 environment who is member of below given groups
1)Discovery management group
2)Mailbox import export
when I am trying to delete mail I am getting error like:
“The target mailbox or .pst file path is required”.
please any one can help in this regard.