none
Please help me with this Search-Mailbox -DeleteContent query RRS feed

  • Question

  • Hi 

    I can use the below to successfully return the desired result.

    Search-Mailbox -identity "james.fulassian@example.co.uk" -SearchQuery {Subject: "test*" Received:11/09/2019..12/09/2019}  -TargetMailbox "RISo365Alerts@example.co.uk" -TargetFolder "Spam Searches" -LogLevel Full

    The next step would be to delete the items returned in the search. For that I need  -DeleteContent 

    I have fairly basic scripting knowledge how could I get -DeleteContent to work with the above?

    Would I pipe it to -DeleteContent or am I over thinking it?  Would it be best to use a variable? 


    • Edited by Pete LakerMVP, Moderator Sunday, September 22, 2019 8:31 PM fixed title for better SEO and helper attraction
    Sunday, September 22, 2019 5:59 PM

All replies

  • Hi RickG67,

    Here are some information about Search-Mailbox command:

    1. When you use  -TargetMailbox and  -TargetFolder, it will copy the result to target mailbox.

    Search-Mailbox -identity *** -SearchQuery ***  -TargetMailbox "****" -TargetFolder "****" -LogLevel Full

    2. When you use -EstimateResultOnly, it will generate a report in EMS, it will not export the result to other mailbox:

    Search-Mailbox -identity *** -SearchQuery ***  -EstimateResultOnly

    3. If you want to delete those email from source mailboxes, you should use -DeleteContent:

    Search-Mailbox -identity *** -SearchQuery ***  -DeleteContent

    Based on your description, you have exported result from source mailbox to target mailbox. If you want to delete them from source mailbox, you need to run the third command.

    Regards,

    Kyle Xu


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    • Proposed as answer by Troy Werelius Monday, September 23, 2019 11:35 AM
    Monday, September 23, 2019 2:35 AM
    Moderator
  • Hi RickG67,

    I am writing here to confirm with you how thing going now?

    If the above suggestion helps, please be free to mark it as an answer for helping more people.

    Regards,

    Kyle Xu


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Wednesday, September 25, 2019 9:32 AM
    Moderator