Exchange Mailbox backups for previous month

This topic contains 1 reply, has 2 voices, and was last updated by  Don Jones 2 years, 6 months ago.

  • Author
  • #32829

    Paramjot Singh

    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".
  • #32903

    Don Jones

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

You must be logged in to reply to this topic.