New-MailboxExportRequest

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Jarkko Vepsäläinen Jarkko Vepsäläinen 3 weeks, 2 days ago.

  • Author
    Posts
  • #74297
    Profile photo of Sayed Hussein Mahdi
    Sayed Hussein Mahdi
    Participant

    Hi,

    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?

    Thanks

  • #74305

    Hi

    Seems like your dates are not correct. First google site: https://thoughtsofanidlemind.com/2011/10/21/date-range-exports-with-new-mailboxexportrequest/ 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
    

    Regards

    Jarkko

You must be logged in to reply to this topic.