How to delete messages in Exchange 2013

I was tasked with deleting email over a year old in the former owners’ mailbox.

I want to do it without taking full control of his mailbox.

I thought this would do it, but it is doing nothing.

Search-Mailbox -identity [USERNAME] -searchquery {(Received:> 01/01/2016 and kind:email)} -DeleteContent -Force


I have tired it on his mailbox and mine, it does not delete anything.


Any suggestions?

Hi Tom,

In order for query to work, spaces should be avoided as they are treated as free text. I see you have space between received and the value. And :> is not a valid operator. Please refer to this page:


Also boolean operators should be written uppercase.

so try with this:

{Received>01/01/2016 AND kind:email}




I do not think it is syntax at this point.
I can do

Search-Mailbox -identity "username" -searchquery subject:"test123" -deleteContent -Force
Search-Mailbox -identity "tim taylor" -searchquery 'subject:"test123"' -deleteContent -Force

no matter what I run, I get a Success: False

I have confirmed I am a member of Organization Management, Import export, and Mailbox Import Export, and that Administrator is as well.
I am also a member of Compliance Management, Delegated setup, Delivery Management, Help Desk, Public Folder Management, Recipient Management, Records Management, Server Management, and View-Only Organization Management.

You have to be logged on with an Exchange admin account to run these commands successfully or an least start you PS session with that account.

Are you even getting a response for just a lookup search first, vs trying a delete?
$ExchangeAdmin = 'Administrator'
$UserTarget = 'testuser'

$MailParams = @{
    Identity      = $UserTarget
    TargetMailbox = $ExchangeAdmin
    SearchQuery   = 'Test EWS PoSH script'
    TargetFolder  = 'SearchLogs LogOnly'
    LogLevel      = 'Full'
Search-Mailbox @MailParams

# Results of Search

WARNING: The Search-Mailbox cmdlet returns up to 10000 results per mailbox if a search query is specified. To return more than 10000 results, use the
 New-MailboxSearch cmdlet or the In-Place eDiscovery & Hold console in the Exchange Administration Center.

Identity         : 001
TargetMailbox    :
Success          : True
TargetFolder     : \SearchLogs LogOnly\TestUser 001-10/19/2018 8:36:34 PM
ResultItemsCount : 2
ResultItemsSize  : 76.61 KB (78,448 bytes)

You can try using the range operator in your dates “…”
Just make the starting date is something really old that you know will encompass everything:
We’ll also use -EstimateResultsOnly to preview if it is working and returning messages. You can change to delete after you can prove that you’re getting a message count

Search-Mailbox -identity [USERNAME] -searchquery "Received:01/01/2000..01/01/2016","Kind:email" -EstimateResultsOnly

I changed it to match my environment, and success is still false.
I copied the script to one of the exchange servers, logged in as Domain Admin to the exchange server, and ran it, same results.

RunspaceId : [GUID}
Identity :
TargetMailbox :
Success : False
TargetFolder : \SearchLogs LogOnly
ResultItemsCount : 0
ResultItemsSize : 0 B (0 bytes)

I Like Cheese
I still get success of False, even logged directly into the exchange server as Domain Admin
RunspaceId : GUID
Identity :
TargetMailbox :
Success : False
TargetFolder :
ResultItemsCount : 0
ResultItemsSize : 0 B (0 bytes)