Delete Mails in Exchange Mailbox in specific folder

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.

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.

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