5

I am attempting to extract a certain date-range of emails from a mailbox into a PST, but using a DateTime parameter for ContentFilter doesn't seem to work as expected.

This should export everything for the last 5 days:

$endDate = Get-Date "00:00:00"
$startDate = $endDate.AddDays(-5)

Write-Host "Exporting items between $startDate and $endDate..."

New-MailboxExportRequest -ContentFilter {(Received -ge $startDate) -and (Received -lt $endDate)} -Mailbox "EmailLog" -FilePath "\\ReadyNAS\backup\Mailboxes\EmailLog\EmailLog.pst"

But the PST ends up with the full 15+Gb of the mailbox in it.

If I specify the dates manually, it works fine:

New-MailboxExportRequest -ContentFilter {(Received -ge "01-06-2013 00:00:00") -and (Received -lt "06-06-2013 00:00:00")} -Mailbox "EmailLog" -FilePath "\\ReadyNAS\backup\Mailboxes\EmailLog\EmailLog-man.pst"

I'm not sure if this is due to some sort of regional-settings conflict, but I would have thought that passing a typed parameter would avoid that sort of sillyness. The reason I suspect this is because if I print out the dates (the Write-Host in the first example) the dates come out in US format:

[PS] C:\Windows\system32>Write-Host "Exporting items between $startDate and $endDate..."
Exporting items between 06/01/2013 00:00:00 and 06/06/2013 00:00:00...
  • 1
    Did you ever come up with a resolution for this? I am experiencing the same issue. – Johnrad Apr 28 '14 at 15:42
1

I confirm I have solved this by specifying the content filter exactly as "(Received -ge '$startDate') -and (Received -lt '$endDate')" to prevent it from becoming $null with help from this question.

My client's Exchange Server 2013 version/build no. is 15.0.847.32.

It could be a rare condition, still I added my answer here just in case it helps someone.

Edit: Based on the concept, I have written a PowerShell Script to archive Journal Mailbox monthly with email reporting.

| improve this answer | |
0

Yes its a known bug The workaround is to change the mailboxes date format to US format export, do the backup then change back to your own regional format, and run the script from an account using US regional settings.

ie

Get-mailbox -Server $Server -resultsize unlimited | Set-MailboxRegionalConfiguration -Language 1033 -DateFormat "M/d/yyyy"

Messy.

| improve this answer | |
  • Cool, that sounds like it might fix the problem. Is it possible to set the regional settings for the current account to US, just for the current session? Or do I have to have a new user that has these settings? – Cylindric Aug 2 '13 at 9:48
  • @Justin, do you have a link with published information about that bug? – SturdyErde Jul 12 '16 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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