If i run the following

$3MonthsBack = Get-Date (Get-Date).AddMonths(-3) -f MM/dd/yyyy
New-MailboxExportRequest -mailbox [email protected] -IncludeFolders akriv -ContentFilter{Received -lt "$3MonthsBack"} -FilePath "\\sto-cm-01\Test\$BatchName.pst" -name "$BatchName" -ExcludeDumpster

I get this:

The provided ContentFilter value is invalid. ContentFilter is invalid. The value "$3MonthsBack" could not be converted to type System.DateTime. --> The value "$3MonthsBack" could not be converted to type System.DateTime.

When I check the system clock it is formated 6/29/2016 and if i run $3MonthsBack it spits out 03/29/2016 (Same format?)

How do i fix this?

  • there is no space between argument name and parameter in -ContentFilter{Received -lt "$3MonthsBack"} - is this a typo?
    – Sergei
    Jun 29, 2016 at 10:14
  • Added a space between and that didn't change the result.
    – Jakodns
    Jun 29, 2016 at 10:15
  • Get-Date (Get-Date).AddMonths(-3) should work just fine. Is it working this way? Does it have to be in that format?
    – Sergei
    Jun 29, 2016 at 10:50
  • Same issue using Get-Date (Get-Date).Addmonths(-3)
    – Jakodns
    Jun 29, 2016 at 11:54
  • 1
    Well shit, That worked. I'll fiddle around a bit more with it to see what works and what doesn't work and update the post.
    – Jakodns
    Jun 29, 2016 at 13:19

2 Answers 2


I was looking for a solution to this problem, it was driving me mad!

I took bit and pieces from the mentioned article, this article from mysysadmintips.com and this article from Occasional Utility.

I did some further research into New-PSSession and New-PSSessionOption. Finally got it working using a PSSession and splatting.

No need to change the regional settings on your Exchange server.

$SessionOption = New-PSSessionOption -Culture 'en-US'
$PSSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://<ExchangeServer>/PowerShell/" -SessionOption $SessionOption

$DateRangeStart = ([datetime]::Today).Addmonths(-3) # 3 months from today
$DateRangeEnd = [datetime]::Now # Now :)

$ExportParam = @{
        Name = <RequestName>
        Mailbox = <Mailbox>
        ExcludeDumpster = $true
        FilePath = <ExportPath>
        ContentFilter = "((Received -le '"+$DateRangeEnd+"') -and (Received -ge '"+$DateRangeStart+"')) -or ((Sent -le '"+$DateRangeEnd +"') -and (Sent -ge '"+$DateRangeStart+"'))"

Invoke-Command -Session $PSSession -ScriptBlock {New-MailboxExportRequest @ExportParam}

After @sergei help, I have now found out how to solve it.

With New-Mailboxexportrequest you have to wrap the text and with " instead of {

That means the This article needs to be updated to change it away from:

-ContentFilter {Received -lt '$Variable'}


-ContentFilter "Received -lt '$Variable'"

You must log in to answer this question.

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