Exchange Mailbox backups for previous month

Hi I am trying to write new script which is supposed to take backup of all mailboxes to shared location for previous month. Say If I run the script on Dec. 10’ 2015 then it will export all mailboxes from Nov. 10 to Dec. 10 2015 and in future if I run script on Dec 24’ 2015 it have to export mailboxes from Nov. 24 to Dec. 24’ 2015. Here’s the script which I am trying.

$Export = Get-Mailbox
$endDate = $endDate.AddMonths(-1)
$month = "{0:D2}" -f [int]$startDate.Month

$endDate = $endDate.ToShortDateString()
$startDate = $startDate.ToShortDateString()

New-MailboxExportRequest -ContentFilter {(Received -ge $startDate) -and (Received -lt $endDate)} -Mailbox $Export -FilePath "\\FileServer\EmailBackups\ExportTest\MonthTest\$($_.alias).pst"
Write-Host "Done".

That looks great. However, you haven’t mentioned if you’re having a problem or need a question answered.