Have been playing with New-MailboxExportRequest cmdlet exporting emails for specific date ranges and found what looks like Exchange Management Shell bug.
On Exchange 2010 SP2 server with UK English region run following command:
New-MailboxExportRequest -ContentFilter {(Received -ge ’01/05/2012′) -and (Received -le ’01/06/2012′)} -Mailbox “user.name” -FilePath “\\server\share\username.pst”
Everything works as expected and all May 2012 emails are exported. However, following command fails:
New-MailboxExportRequest -ContentFilter {(Received -ge ’01/05/2012′) -and (Received -le ’31/05/2012′)} -Mailbox “user.name” -FilePath “\\server\share\username.pst”
Error:
The provided ContentFilter value is invalid. ContentFilter is invalid. The value “31/05/2012” could not be converted to type System.DateTime. –> The value “31/05/2012” could not be converted to type System.DateTime.
+ CategoryInfo : InvalidArgument: ((Received -ge ‘…e ’31/05/2012’):String) [], ContentFilterInvalidPermanentException
+ FullyQualifiedErrorId : 3307495E
After some additional testing I found that regardless of server regional settings Exchange Management Shell always performs data check assuming US English date format (MM/DD/YYYY). You can’t simply use US English format in a command as a workaround as actual cmdlet does respect system’s regional settings (that’s why first example exports all May 2012 emails, not 5 January 2012).
Here a couple of possible workarounds:
- One way to get around this is to only use days between 1 and 12 in the command.
- if you can’t do this, you can temporarily change server’s regional settings to US English. Restart Exchange Management Shell and run the command using US date format.
Update:
The issue seems to affect newer versions of MS Exchange as well, including Exchange 2016. Also, in some cases, depending on date formatting, it can look like the export command succeeded, but after a few seconds in a Queued state in changes to Failed. To view actual error, you can run: Get-MailboxExportRequest | Get-MailboxExportRequestStatistics -IncludeReport | Ft Report -Wrap. In that, case the error was:
Fatal error InvalidContentFilterPermanentException has occurred
The attempt to deserialize failed for type: ‘System.UnitySerializationHolder’
Leave a Reply