Removing/Deleting Messages from mailboxes in Exchange 2010 SP1 RRS feed

  • Question

  • Does anyone have a how to guide or a blog they can point me to that shows how to remove/delete an email based on keyword in subject field or body or even attachment name? We have Exchange 2010 SP1. From what I understand there is a new command for handling this... The typical scenario would be running this against multiple mailboxes.

    I'm coming from Exchange 2003 so Exmerge was my friend. :)



    Thursday, November 4, 2010 8:47 PM


All replies

  • Does this help?


    Tim Harrington - Catapult Systems -
    Thursday, November 4, 2010 8:53 PM
  • Tim,

    Thanks for the link but it says in that article:

    In Exchange 2010 RTM and Exchange 2007, you can use the Export-Mailbox cmdlet to export or delete messages. In Exchange 2010 SP1, the functionality to export a mailbox is provided by the New-MailboxExportRequest cmdlet and is covered in a separate article. 


    Anyone seen that one yet? or have another?



    Thursday, November 4, 2010 9:03 PM
  • Check this one...Section "Advanced Export Mailbox Request Commands"


    Tim Harrington - Catapult Systems -
    Thursday, November 4, 2010 9:19 PM
  • 1. add the user you are going to use to the AD group "Discovery Management"

    2. Logon as this user and run EMS 

    3. get-mailbox -resultsize unlimited | search-mailbox -SearchQuery "Subject:'whatever'" -DeleteContent



    blog | twitter
    Thursday, November 4, 2010 10:07 PM
  • And please note, if you want to run the cmdlet Search-Mailbox with parameter -DeleteContent, you must also be assigned the "Mailbox Import Export" Role. By default, the "Mailbox Import Export" role isn't assigned to any role group.

    How to Add a Role to a User or USG

    Frank Wang
    Tuesday, November 9, 2010 3:10 AM
  • With the search-mailbox command can you also search out and delete any email based on attachment name? Reading another forum post on this, there is discrepancy on this specific point.

    In times past, we've had issues where HR accidentally sends payroll information in a spreadsheet to the wrong people. They want us to do a search and destroy based on attachment name. 


    Here are comments from the article mentioned earlier from TW...just wanted to get this question ironed out...


    Bharat Suneja [MSFT] said:

    @Daniel: As mentioned in the post, you can use the Search-Mailbox cmdlet, which has the -DeleteContent switch. See Use Mailbox Search to Delete Messages.
    October 28, 2010 6:47 PM

    Anthony said:

    Can you document which property keywords are available to Search-Mailbox?  I am trying to delete all messages that do not have attachments and hasattachment:false, hasattachment:no, hasattachments:no, isattachment:false, and isattachment:no do not work.
    October 28, 2010 7:19 PM

    Bharat Suneja said:

    @Anthony: You can use keywords supported by Exchange Search. See Understanding Exchange Search for a list. The HasAttachmentkeyword isn't one of them.   

    If you use unsupported keywords in SearchQuery, you'll get an error stating The property keyword isn't supported.
    October 29, 2010 4:01 PM

    Andrew phillips said:

    @Bharat: The link you provided on Enderstanding Exchange Search shows this example: 

    From:"April Stewart" HasAttachments:true Subject:Contoso. 

    Is the example wrong or perhaps misleading in showing the use of "HasAttachments"?

    Tuesday, November 9, 2010 1:33 PM
  • yes attachment name is possible using the 


    get-mailbox -resultsize unlimited | search-mailbox -SearchQuery "attachment:report.xlsx" -DeleteContent


    more info


    blog | twitter
    • Proposed as answer by emma.yoyo Wednesday, November 10, 2010 2:45 AM
    • Marked as answer by slammers25 Wednesday, November 10, 2010 1:27 PM
    Tuesday, November 9, 2010 1:42 PM
  • All,

    I need to remove messages from multiple Exchange 2010 SP1 mailboxes, but using  "get-mailbox -resultsize unlimited | search-mailbox -SearchQuery "Subject:'whatever'" -DeleteContent" is not giving me the flexibility to remove messages from particular period.

    Includding I'm also trying to export message to a mailbox.

    Any idea. 

    Zahir Hussain Shah Infrastructure Practice Consultant My blog:
    Sunday, July 3, 2011 8:57 AM
  • I am having the same issue - Exchange 2010 SP1 and get-mailbox -resultsize unlimited | search-mailbox -SearchQuery "Subject:'whatever'" -DeleteContent" is not working for me.

    Anyone - any ideas?

    Friday, December 28, 2012 1:08 AM
  • Not sure about the rest... but it looks like "attachment:'*'" works to find "any" attachment in the search query part, or you can put in a specific document name.

    BYoung, Sr. Server Analyst

    Tuesday, April 30, 2013 3:08 PM
  • Hi,

    How to delete specific period mails from single mailbox.



    Friday, September 20, 2013 11:27 AM
    1. You can use the MS tools by following this link
    2. Or is you want something a bit more intuitive check out Lucid8's DigiScope

    Search, Recover, & Extract Mailboxes, Folders, & Email Items from Offline Exchange Mailbox and Public Folder EDB's and Live Exchange Servers or Import/Migrate direct from Offline EDB to Any Production Exchange Server, even cross version i.e. 2003 --> 2007 --> 2010 --> 2013 with Lucid8's DigiScope

    Saturday, September 21, 2013 12:41 AM
  • Hello Zahir

    Do you find a way to remove mails for a period of time? For a specific date and for a specific subject I can able to delete them as seen below

    get-mailbox -identity User1 -resultsize unlimited |  search-mailbox -SearchQuery "subject:""Me too added connections you may know""  Sent:08/13/2012" -TargetMailbox user2 -TargetFolder Inbox –LogOnly  -LogLevel Full



    Wednesday, August 13, 2014 7:40 AM