After reading: http://technet.microsoft.com/en-us/library/dd298173(v=exchg.150).aspx
which links off to: http://msdn.microsoft.com/library/ee558911%28v=office.15%29.aspx
I made the following PowerShell script for testing before I start deleting anything:
$A=Get-Date '18/7/2014' $Start=Get-Date $A.ToUniversalTime() -Format yyyy-MM-ddThh:mm:ss $End=Get-Date $A.AddDays(1).ToUniversalTime() -Format yyyy-MM-ddThh:mm:ss $SearchQuery='Received>="'+$Start+'" AND Received<"'+$End+'"' Search-Mailbox -Identity 'mailbox@domain' -SearchQuery $SearchQuery -TargetMailbox 'targetmailbox@domain' -TargetFolder Inbox -LogOnly -LogLevel Full
The results I get back are all the emails between 17/7/2014 12:00 AM - 18/7/2014 12:00 AM
When I thought it should be the emails between 17/7/2014 2:30 PM - 18/7/2014 2:30 PM (Our time zone is +9:30)
Does the query I'm passing to -SearchQuery need tweaking or am I doing something else wrong?
The $SearchQuery variable expands out to this:
Received>="2014-07-17T02:30:00" AND Received<"2014-07-18T02:30:00"
I'm using the Search-Mailbox cmdlet because is wish to adjust this script to use the -DeleteContent paramater