Forum Discussion
Schnittlauch
Feb 28, 2024Steel Contributor
Get-MailboxExportRequest doesn't accept Export from date A to date B
Hi everyone,
I'm faceing a strange error, when I want to export between 2 dates.
We've tried infinite ways of exporting between 2 dates, but me and my colleagues can't get it.
For easier reading, I reduced the following code to the minimum.
We are successfully exporting with Case 1, but as soon as we want to set a end date, it will automatically fail with the wildest excuses. (See 2nd code)
#Define Dates
$start = (Get-Date -Day 1 -month 6 -year 2021 -Hour 00 -Minute 00)
$end = (Get-Date -Day 31 -month 12 -year 2023 -Hour 23 -Minute 59)
#Case 1: Export the MB works with following command WORKS. (So Export from Date X until today):
New-MailboxExportRequest -Mailbox "PrimarySmtpAddress" -ContentFilter "((Received -ge '$start') -and (Sent -ge '$start'))" -FilePath "Path\file.pst"
#Case 2: To keep it simple, I'll just export the received Messages (Export from Date X to Date Y (NOT NOW) doesn't work.:
New-MailboxExportRequest -Mailbox "PrimarySmtpAddress" -ContentFilter "((Received -ge '$start') -and (Received -le '$end'))" -FilePath "Path\file.pst"
Get-MailboxExportStatistics
Error: ContentFilter is invalid. The value "31.12.2023 23:59:00" could not be converted to type
System.DateTime. --> The value "31.12.2023 23:59:00" could not be converted to type
System.DateTime.
$end is definitely a system.datetime type; We've also used different System Cultures, f.e.:
[System.Threading.Thread]::CurrentThread.CurrentCulture = "en-US"
I've been working on this for a long time, please only respond, if you were able to reproduce this in your own Exchange Environment, since I want a confirmation, that this is a (currently) unhandable bug.
Best regards,
Florian
edit: I updated the official MS docs.
No RepliesBe the first to reply