Author Posts

July 5, 2017 at 5:47 am


I'm trying to automate the exporting process of a particular mailbox to PST, so I created this simple script:

$Firstdayofthismonth = Get-Date -day 1 -Hour 0 -Minute 0 -Second 0
$Firstdayoflastmonth = (Get-Date -day 1 -Hour 0 -Minute 0 -Second 0).AddMonths(-1)

New-MailboxExportRequest -Mailbox "UserMailbox" -FilePath "Path to the PST" -ContentFilter {(Received -lt $Firstdayofthismonth) -and (Received -ge $Firstdayoflastmonth)}

the idea is, after the end of one month the script would run and export last-one-month worth of emails to PST, but when I ran the script for testing, it exported the entire mailbox rather than only last month, maybe the -contentfilter parameter doesn't accept variables?

Can anyone help?


July 5, 2017 at 9:20 am


Seems like your dates are not correct. First google site: says following

New-MailboxExportRequest -ContentFilter {(Received -lt '04/01/2010') -and (Received -gt '03/01/2010')} -Mailbox "Pelton" -Name DPeltonExp -FilePath \\ExServer1\Imports\DPelton.pst