Exchange 的 New-MailboxExportRequest 对 ContentFilter 的 DateTime 参数表现得很奇怪

Cyl*_*ric 5 powershell exchange-2010

我试图从邮箱中提取特定日期范围的电子邮件到 PST,但使用 DateTime 参数ContentFilter似乎没有按预期工作。

这应该导出过去 5 天的所有内容:

$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"
Run Code Online (Sandbox Code Playgroud)

但是 PST 最终会在其中包含完整的 15+Gb 邮箱。

如果我手动指定日期,它工作正常:

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"
Run Code Online (Sandbox Code Playgroud)

我不确定这是否是由于某种区域设置冲突造成的,但我认为传递类型化参数会避免这种愚蠢行为。我怀疑这是因为如果我打印出日期(第一个示例中的 Write-Host),日期会以美国格式显示:

[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...
Run Code Online (Sandbox Code Playgroud)

小智 0

是的,它是一个已知错误。解决方法是将邮箱日期格式更改为美国格式导出,进行备份,然后更改回您自己的区域格式,并从使用美国区域设置的帐户运行脚本。

IE

Get-mailbox -Server $Server -resultsize unlimited | Set-MailboxRegionalConfiguration -Language 1033 -DateFormat "M/d/yyyy"
Run Code Online (Sandbox Code Playgroud)

凌乱的。