2

I am trying to export a mailbox to a PST. All email that was received before yesterday is what I am trying to export.

$y = ((get-date).addDays(-1)).ToShortDateString()
$exportRequest = New-MailboxExportRequest -ContentFilter {(Received -lt $y)} -mailbox userID -FilePath\\SHARED\folder\userID.pst

Something is not right here. I end up exporting the entire mailbox.

When I run a:

Get-MailboxExportRequest | Get-MailboxExportRequestStatistics | select ContentFilter

It says that my content filter is:

Received -ne $null

I am sure something is wrong with my syntax here, but I can't seem to get it.

1 Answer 1

3

It's a finicky syntax error and made worse by incorrect/unclear documentation. Please try the following --

$y = ((get-date).addDays(-1)).ToShortDateString()
$exportRequest = New-MailboxExportRequest -ContentFilter "Received -lt '$y'" -mailbox userID -FilePath \\SHARED\folder\userID.pst
3
  • I am still getting the same error with this. I feel like I have tried nearly every possible way of doing this. I have triple checked my time format... Everything.
    – Johnrad
    Apr 28, 2014 at 16:36
  • Well not everything.... Can you explain to my why this worked Received -lt '$($y)'
    – Johnrad
    Apr 28, 2014 at 16:40
  • 2
    I can't explain it. I just played around with it a bit and settled on -ContentFilter "Received -lt '$y'" as the simplest accepted syntax. I couldn't really say why it doesn't work for you. Your alternatively proposed method also works on my machine, but I don't know why it seems to be necessary. More disturbingly, the official documentation flat-out doesn't work for either of us.
    – pk.
    Apr 28, 2014 at 17:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .