Delete Mails in Exchange Mailbox in specific folder

This topic contains 2 replies, has 2 voices, and was last updated by  Ian Fermer 2 years, 11 months ago.

  • Author
  • #26908

    Kevin Sanders

    Hi there,

    I'm looking at a clients exchange where they have a mailbox with large amounts of emails,

    I need to delete all the mails in a specific folder.I tried the following one liner and multiple like it and did not get it working

    Search-Mailbox -Identity "name" -TargetMailbox "Mailboxname" -TargetFolder "foldername" -LogLevel Full -DeleteContent

    Can you please help asap.

  • #26909

    Kevin Sanders

    When I run it form the exchange shell I get the following message

    WARNING: The source mailbox 'mailbox' will not be searched because it is the target mailbox. The source mailbox
    cannot be used as the target mailbox.

  • #26962

    Ian Fermer

    You cannot search a specific folder I believe, you can fine tune to when sent it or received

    search-mailbox -identiy "Mailbox ID" -searchquery {Sent:"06/30/2015"} -deletecontent

    Note the date format though

You must be logged in to reply to this topic.