Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've been using Microsoft Exchange Server 2010 SP2. I want to delete user's mails within specific date range. How can I do that? BTW, When to running below command then I've got the following the error.

Search-Mailbox -Identity xxxxx -SearchQuery "Received:> $('01/01/2009') and Received:< $('12/31/2009')" -DeleteContent

Here is my error message :

A search keyword should not be preceeded with comparison modifiers eg. '<', '>', '='.    
+ CategoryInfo          : InvalidArgument: (:) [], ParserException    
+ FullyQualifiedErrorId : 61B67608

UPDATE :

As you mentioned,I've done literally your comments. But ,

Even though about 6000 emails within user's mailbox,it's returned 18 emails below command.

Search-Mailbox -Identity xxxxxxx -SearchQuery {((Received -lt '01 Oct 2009') -and (Received -gt '01 Aug 2013'))} -TargetMailbox targetmailbox -TargetFolder testxx -LogOnly
share|improve this question
    
replace the > and < with -gt and -lt. –  tony roth Aug 19 '13 at 15:06
    
I've updated my post. –  Cell-o Aug 20 '13 at 14:38
    
Any comments?.. –  Cell-o Aug 22 '13 at 5:56
    
so you want email prior to 10/1/2009 and after 8/1/2013? not between? –  tony roth Aug 29 '13 at 18:17

1 Answer 1

The reason for you error is because special characters are not escaped. The easiest way is to use double quotes around the value instead of single quotes. Also if you'd like to use a date range then you can use the '..' operator. http://msdn.microsoft.com/en-us/library/office/ee558911(v=office.15).aspx#kql_property_restriction_queries

So Search-Mailbox xxxxx -SearchQuery "Received:(1/1/2009..12/31/2009)"

This will search for all mail received between 1/1/2009 12:00 am and 12/31/2009 12:00 am.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.