I want to backup Exchange messages incrementally each month. I've tried these scripts:
$d = (Get-Date).AddMonths(-1)
New-MailboxExportRequest -ContentFilter {Received -gt $d} -Mailbox "username" `
-name UserInc -filepath \\some\server\share\userinc.pst
and
$d = (Get-Date).AddMonths(-1).ToString('MM/dd/yyyy')
New-MailboxExportRequest -ContentFilter {Received -gt $d} -Mailbox "username" `
-name UserInc -filepath \\some\server\share\userinc.pst
Both scripts back up all messages in the mailbox.
Whereas:
New-MailboxExportRequest -ContentFilter {Received -gt '05/01/2016'} -Mailbox "username" `
-name UserInc -filepath \\some\server\share\userinc.pst
And:
$d = '05/01/2016'
New-MailboxExportRequest -ContentFilter {Received -gt $d} -Mailbox "username" `
-name UserInc -filepath \\some\server\share\userinc.pst
work flawlessly. Where am I going wrong?
This turned out to be a really nasty i18n bug in the Exchange Management Shell. Even though the ContentFilter expects a DD/MM/YYYY date for a UK Exchange installation, it still checks the date against the US format. This means that the date checks only work for the first twelve days of each month.