Date range exports with New-MailboxExportRequest


From Exchange 2010 SP1 onward, a new method is used to export and import mailbox data. Instead of forcing administrators to run Outlook on a mailbox server so as to be able to use Outlook’s ability to read and write PSTs, Exchange 2010 SP1 contains brand-new code for PST access and eliminates any need to run Outlook. This is a very good thing as it’s always best not to run applications designed for client computers on servers.

The new code is exposed through a set of cmdlets that mimic the approach taken for mailbox moves. In other words, you create a new request to export or import data, you can manipulate or  view properties of a request, you can fetch request statistics, remove a request from the queue, and so on. The actual processing of the requests is performed by the Exchange Mailbox Replication Service (MRS) running on a Client Access Server (CAS), just like mailbox moves.

We are still getting used to the new implementation and it’s not surprising that we’re still discovering the breadth of the capabilities provided by its developers. One such example occurred recently when the question was posed as to the best way to export data for a particular date range. I think this is likely to be a pretty common request as you obviously don’t want to be forced to export the complete contents of a mailbox unless absolutely necessary, especially as mailboxes get larger and larger. No only would such an export take longer than required for a subset, it also exposes additional possibility that confidential user data might be compromised inadvertently. In other words, the fewer items that you export from a mailbox, the less chance that any item might be viewed by someone other than its owner.

At first glance, the set of available parameters for the New-MailboxExportRequest cmdlet don’t seem to include anything that can help, until you notice the hidden gem that’s buried in the ContentFilter parameter.

For more information about filterable properties, see Filterable Properties for the -ContentFilter Parameter.

There’s a huge range of filterable properties that can be explored. For this purpose the best parameter is “Received”, which takes date stamps as its input and allows you to search for items that match a particular date span.

Note: The New-MailboxImportRequest cmdlet does not support a ContentFilter parameter. This might be because it’s easier to implement a filter like this when dealing with server-based data that is already indexed (Exchange 2010 indexes every item in every mailbox automatically) whereas applying a filter to information held in a PST wouldn’t be as effective or efficient. The PST file format is, after all, not the greatest structure that the world of IT has ever seen.

As an example of date range filtering in action with New-MailboxExportRequest, this code looks for any item (in any folder) that has a received date in the range 2 March 2010 to 31 March 2010 from the “Pelton” mailbox [this is an update from the original post – see Matt’s comment below]. Any items that are found are exported to a PST in the specified file share (FilePath). See this post for more information about configuring a network file share as a repository for mailbox import and export requests.

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

Exporting a date range of items using New-MailboxExportRequest

Unfortunately there’s no GUI available for the New-MailboxImportRequestNew-MailboxExportRequest, and their associated cmdlets so everything has to be done through the Exchange Management Shell (EMS). Such is life. The good thing is that the possibility exists to export items using a date range and that we’ve learned more about the potential that lurks behind the ContentFilter parameter, but only for mailbox exports.

– Tony

Follow Tony @12Knocksinna

About Tony Redmond

Lead author for the Office 365 for IT Pros eBook and writer about all aspects of the Office 365 ecosystem.
This entry was posted in Exchange 2010 and tagged , , . Bookmark the permalink.

94 Responses to Date range exports with New-MailboxExportRequest

  1. Hi Tony,

    Your syntax is not entirely correct, you say that your export command will grab March 1 – April 1, however in reality it grabs everything between March 1 – April 1 (March 2 – March 31).

    I use -ge (greater-than-or-equal-to) instead of -gt (greater-than) on the first day, this will always give you the full month of March. Of course if you needed to include April 1 as well you could use -le (less-than-or-equal-to) on the “high” side of the range in place of -lt (less-than).

    PS> New-MailboxExportRequest -ContentFilter {(Received -lt ’04/01/2010′) -and (Received -ge ’03/01/2010′)} -Mailbox “Pelton” -Name DPeltonExp -FilePath \\ExServer1\Imports\DPelton.pst

    Also you stated that will grab any item in any folder, it is important to note that this will not include sent items, since they were never “Received”. Below will grab both sent and received from all folders within the month of March.

    PS> New-MailboxExportRequest -ContentFilter {(Received -lt ’04/01/2010′) -and (Received -ge ’03/01/2010′) -or (Sent -lt ’04/01/2010′) -and (Sent -ge ’03/01/2010′)} -Mailbox “Pelton” -Name DPeltonExp -FilePath \\ExServer1\Imports\DPelton.pst

    -matt

  2. Tomasz says:

    Hello
    I’ve got problem with use this in a script. It is look like:
    $Date=Read-Host
    New-MailboxExportRequest -Mailbox user -FilePath \\server\A$\User.pst -ContentFilter {(Received -lt ‘$Date’) -and (Sent -lt ‘$Date’)}

    There is a problem with using variable $Date in ContentFilter.
    ———————
    Error:
    The provided ContentFilter value is invalid. ContentFilter is invalid. The value “$Date” could not be converted to type System.DateTime. –> The value “$Date” could not be converted to type System.DateTime.
    ———————
    I tried with: ‘$Date’, $Date, “$Date” … still the same problem.

    Do you have any idea how to solve this problem?
    Kind Regard
    Tomasz

  3. Joshua Thompson says:

    Is it possilble to MOVE the messages to the PST rather than just copying them?

    • It would be a two stage process. First, copy the messages to the PST and then search the mailbox (using Search-Mailbox) for the same messages and remove the content (pass the DeleteContent parameter)

      TR

      • Joshua Thompson says:

        My export command and search results command are producing different results. Would you happen to know why?

        In my Test scenario there should be exactly 1 message that is exported from this query. It is not exported. The search query does delete 1 message however.

        Export:
        New-MailboxExportRequest -ContentFilter {(Received -ge ’02/01/2012′) -and (Received -le ’02/08/2012′)} -Mailbox “MailboxName” -Name MailboxExportName –FilePath “Path to PST”

        Search:
        Search-Mailbox MailboxName -SearchQuery “Received:>= $(’02/01/2012′) and Received:<= $('02/08/2012')" -DeleteContent

      • The commands look good. It’s impossible to understand why you’re seeing a difference without examining the properties of the item.

        TR

  4. Joshua Thompson says:

    I got it. I needed to include the time stamp as well.

    New-MailboxExportRequest -ContentFilter {(Received -ge ’02/01/2012 00:00:00′) -and (Received -le ’02/10/2012 23:59:59′)} -Mailbox “MailboxName” -Name MailboxExportName –FilePath “Path to PST”

  5. charlieandchina says:

    I have a furter question about the need to “Move” ….
    Previously with Export-Mailbox I could use the Deletecontent parameter in a single command line, is this still possible with the new cmdlet?

    To be fair, I don’t know if the previous syntax actually ran the process twice (ie once to export and then repeated to delete), or whether it did it as one operation.

    Reason I need this, I have a few users with massive mailboxes that I need to export by year to a pst file to hand back to them (they are not capable of doing this themselves – read “senior management”)

    Cheers
    S

    • You can’t delete content with New-MailboxExportRequest… you’ll have to export the data and then delete it with Search-Mailbox!

      TR

      • charlieandchina says:

        Thanks Tony – at least the new process seems to run a lot faster than the previous method, so although it’s a two step procedure, it is quicker overall.

        I guess I need to look at scripting it into one action – not my forte, but might as well bite the bullet !

        Rgds
        S

  6. Fred says:

    Hi Tony – I was hoping you can help me with an issue I’m having when running the following command:

    New-MailboxExportRequest -ContentFilter {(Received -lt ’10/21/2011 11:59:00 PM’) -and (Received -ge ’10/20/2011 12:00:00 AM’)} -Mailbox “mailbox2011” -Name mailbox2011Exp -FilePath “\\server\2011Exp\2011export.pst”

    ‘m getting a “The value “21/10/2011 11:59:00 PM” could not be convered to type System.DateTime.

    Any suggestion as to what is the problem with the command? Thank in advance for your assistance.

    • Hi Fred,

      I noticed a couple of things…

      1) I am assuming that you are in a country (or using a keymap from) where dates are commonly referred to DD/MM/YYYY instead of the more US way of MM/DD/YYYY. I am making this guess based on the inversion of the date in the error. So I would try to flip that around in your command.

      New-MailboxExportRequest -ContentFilter {(Received -lt ’21/10/2011 11:59:00 PM’) -and (Received -ge ’20/10/2011 12:00:00 AM’)} -Mailbox “mailbox2011″ -Name mailbox2011Exp -FilePath “\\server\2011Exp\2011export.pst”

      2) I think you might have the same problem as Tomasz above, try replacing your {} with “” around your content filter. If you are not running this in a script, then it is most likely the first option.

      New-MailboxExportRequest -ContentFilter “(Received -lt ’10/21/2011 11:59:00 PM’) -and (Received -ge ’10/20/2011 12:00:00 AM’)” -Mailbox “mailbox2011″ -Name mailbox2011Exp -FilePath “\\server\2011Exp\2011export.pst”

      http://social.technet.microsoft.com/Forums/en-US/exchangesvradmin/thread

      Also /52866982-94b1-4e08-ae0d-9e42c88c9ae8

      • Fred says:

        Tony, thanks for the prompt response. I’m actually located in Canada, so I believe I’m using the right date format. I tried your suggestions without avail, on both instances I get the following:

        The provided ContentFilter value is invalid. ContentFilter is invalid. Invalid filter syntax. For a description of the
        filter parameter syntax see the command help.
        “(Received -lt ’10/21/2011 11:59:00 PM’) -and (Received -ge ’10/20/2011 12:00:00 AM’)” at position 15. –> Invalid filt
        er syntax. For a description of the filter parameter syntax see the command help.
        “(Received -lt ’10/21/2011 11:59:00 PM’) -and (Received -ge ’10/20/2011 12:00:00 AM’)” at position 15.
        + CategoryInfo : InvalidArgument: ((Received -lt ‘…1 12:00:00 AM’):String) [], ContentFilterInvalidPerm
        anentException
        + FullyQualifiedErrorId : 969E9606

        All I want to do is to be able to export data from a mailbox based on date. Any other suggestions are greatly appreciated.

  7. This worked for me… Exchange 2010 SP2 RU2:
    New-MailboxExportRequest -ContentFilter {(Received -ge ’10/20/2011 00:00:01′) -and (Received -le ’10/21/2011 23:59:59′)} -Mailbox “Mailbox2011” -Name Mailbox2011 –FilePath “\\server\2011Exp\2011export.pst”

    • Fred says:

      Tony, still got the same error I posted in my previous reply.

      • Hi Fred,

        Right now I don’t have access to a server and won’t have until I come back from TEC in San Diego. So I am limited to the Internet (for those that are interested, Exchange Online in Office 365 doesn’t support the New-MailboxExportRequest cmdlet for tenant administrators, for obvious reasons). I suggest that we go back to first principles and consult TechNet. http://technet.microsoft.com/en-us/library/ff601762.aspx provides advice as to the correct use of the -ContentFilter parameter. The example offered there is:

        -ContentFilter {(Sent -lt ’01/01/2010′) -and (Sent -gt ’01/01/2009′)}

        Try using that (just to get the syntax right) and then move on to change the “Sent” to “Received” (shouldn’t be an issue), the comparison operators from “gt” to “ge” (can’t see an issue there). Make sure that syntax works for you. Finally, change the dates. This step by step method will prove each element of the command.

        Sorry that I can’t do more to help but the demands of travel make it impossible.

        TR

      • Tom says:

        I am having the same problems. I’m wondering if there is a bug when handling non-US date format? (I am in Australia – DD/MM/YYYY)

        New-MailboxExportRequest -ContentFilter {(Received -lt ’06/27/2012′)} -Mailbox archive -FilePath \\server\share\tom\archive02.pst

        I have to americanise the date to get the request to queue, but after 5 minutes it will fail with:
        “The value “27/06/2012 12:00:00 AM” could not be converted to type System.DateTime.”

      • Hmmm… Have you tried putting the date and time into a variable and using the variable with New-MailboxExportRequest to see whether that does the trick? It seems like you might be running into some sort of format mismatch between submission (maybe on a PC running an Australian version of Windows?) and execution (on a CAS server running what locale for Windows?). It’s possible that the two run different locales and so cause some problems.

        If not, Paul Cunningham runs ExchangeServerPro.com (or @ExchServPro) out of Australia and has posted a lot of sample PowerShell for people to share. He might have some insight into the problem of working with dates and times on an Australian server.

        TR

      • Josh says:

        I was having the same issue. I finally got it to work with the following syntax:

        New-MailboxExportRequest -ContentFilter {((Received -le ’07/12/2012′) -and (Received -ge ’06/18/2012′)) -or ((Sent -le ’07/12/2012′) -and (Sent -ge ’06/18/2012′))} -Mailbox “MailboxName” -Name MailboxNameExp -FilePath \\server\exports\mailboxname.pst

        Notice the double parenthesis, they are necessary and the -le must be first, then the -ge. Hope this helps.

  8. Fred says:

    Tony, that’s great info and much appreciated. I’ll go through it, btw good idea in changing the background on you blog as it was a bit difficult to read with the provious one.

  9. Alex says:

    Anyone ever come up with a New-MailboxExportRequest command that exported e-mails from a specific folder like SENT ITEMS, that were also of a specific DATE RANGE?

    It doesn’t seem that New-MailboxExportRequest has a switch for this? This used to be doable including deleting those e-mails from the folder before the implemented SP1. Please tell the Exchange team bring this back!

    I’ve tried the Sent filter only and it also retrieves all e-mails “sent TO” the mailbox owner (e.g. John Doe) at the specified date range. I only want to extract the e-mails specifically sent BY the mailbox owner. (e.g. All e-mails sent by John Doe and not including any e-mails sent TO John Doe. It’s just so frustrating… I’ve been going into the mailboxes of users through OWA to do this manually… painful.

    Any help would be very much appreciated.

    • Well, the -IncludeFolders parameter for New-MailboxExportRequest will allow you to limit the export to just one or more specific folders, including Sent Items, and the -ContentFilter parameter allows you to specify a date range. Have you tried playing with these parameters? The ContentFilter accepts a filter such as Sender -eq “Tony” to extract messages specifically from one person. I’m afraid that I can’t be of more help as I’m on the road (Atlanta airport, actually).

      TR

  10. Raph says:

    I believe I may be going loopy here 🙂
    My version of Exchange 2010 SP2 RU2 does not seem to have the New-MailboxExportRequest cmdlet available….Version 14.2 (Build 247.5)
    I believe in one of the comments above you mentioned you are also running this build and it works fine for you?

    I get the following error:
    The term ‘New-MailboxExportRequest’ is not recognized as the name of a cmdlet, function, script file, or operable program.
    The term ‘Get-MailboxExportRequest’ is not recognized as the name of a cmdlet, function, script file, or operable program.

  11. Paul van Eijk says:

    Hi All,

    I just use the following command to export all emails that are from 1 January 2011 or older:

    New-MailboxExportRequest -ContentFilter {(Received -le ’01/01/2011′) -Or (Sent -le ’01/01/2011′)} -Mailbox “username” -Name username -FilePath \\Server02\c$\temp\UsernameEnd2010.pst -IsArchive

    This command run perfectly and the pst file filled. After that I run the DeleteContent command to delete all emails of 1 January 2011 and older that have been Send or Received from the Archive Mailbox:

    Search-Mailbox -Identity “Username” -SearchQuery {(Received -le ’01/01/2011′) -Or (Sent -le ’01/01/2011′)} –DeleteContent

    ALL Emails of Mailbox and Archive Mailbox were deleted :S even emails younger then 1 Januray 2011. What did I do wrong ?

    Greetings Paul

  12. Hi Paul,

    It’s impossible to know what happened here without access to the data. I suggest that you 1) examine some of the items in the archive mailbox with MFCMAPI to establish exactly what values are held in the various properties that you want to filter on and then 2) run some tests with Search-Mailbox (with logging turned on) to establish results that you get against the data. This way you’ll be able to compare the effects of your commands against known data and come to some conclusions.

    TR

  13. Paul van Eijk says:

    Hi Tony,

    Do you happen to know if I can rerstore emails that have been deleted with the SearchQuery -DeletContent option? Because using the SearchQuery option and restore all content back I cannot see all emails. The date range is correct.

    Greetings Paul

    • I don’t actually know if -DeleteContent is a “hard” or “soft” delete. If it’s soft, you should be able to log onto the mailbox and use the recover deleted items feature to retrieve the info. If hard, you’ll have to recover from a database backup. You can restore a backup to a different disk and mount it as a Recovery Database to get the info back.

      TR

  14. This certainly is a scary way to archive user’s email. One wrong date range and Ill delete their whole mailbox! I wish microsoft would leave us with a better option…

  15. Ron Trinidad says:

    Is there a log that will show why these commands would Fail? I am running the following command and it is failing:

    New-MailboxExportRequest -ContentFilter {(Received -lt ’07/19/2012′) -and (Received -gt ’07/11/2012′)} -Mailbox “amills” -Name AMILLS_Second -FilePath \\PRO19-HP\ExchangeExport\amills_2.pst

    • AFAIK, there are no logs available. Try running the command with the -Verbose switch to see if anything particular is complained about. Alternatively, build the command up piece by piece to ensure that your syntax is correct for every piece. I’m assuming that you’re running with an account that has been assigned the Mailbox Import-Export RBAC role and that the PST file is going to be put in a file share that’s available to the Exchange Trusted Subsystem?

      TR

    • Raph says:

      The failed EMS cmdlets get logged by Windows server Event Viewer under Microsoft Application & Services, under the category name: MSExchange Management, however the details aren’t very helpful!

  16. Matthew Dillon says:

    Does the following command remove only e-mail messages or does it also include contacts and calendar events as well?

    Export:
    New-MailboxExportRequest -ContentFilter {(Received -ge ’02/01/2012′) -and (Received -le ’02/08/2012′)} -Mailbox “MailboxName” -Name MailboxExportName –FilePath “Path to PST”

    Search:
    Search-Mailbox MailboxName -SearchQuery “Received:>= $(’02/01/2012′) and Received:<= $('02/08/2012')" -DeleteContent

    • All items are exported by the New-MailboxExportRequest cmdlet if you include all folders. AFAIK, the Search-Mailbox cmdlet should export all items that meet the search criteria. You might have to play around for a while to get the exact set to use, but it should be possible to export calendar and contact items as well. The search terms “kind:contacts” and “kind:meetings” can help you identify specific contact and meeting items.

      TR

  17. Richard says:

    Hey everyone, I’m getting some issues running the very first sytnax with a date range for received and sent items. The error I’m getting is “The provided ContentFilter is invalid. ContentFilter is invalid. Invalid filter syntax” This is a straight copy and paste into notepad, changed the parameters, mailbox, location, etc. Any ideas?

    • Don’t cut and paste direct into PowerShell. Often it works just fine, but my observation is that PowerShell doesn’t like recipient filters and similar pasted in. Type the filter from scratch and see if that works.

      TR

    • Poli says:

      I suggest you to use the (MessageKind -eq ‘Email’) inside the ContentFilter like this:
      New-MailboxExportRequest -ContentFilter {(MessageKind -eq ‘Email’) -and (Received -le ’03/30/2020′)} -Mailbox “mailboxname” -FilePath \\Server\Share\filename.pst
      This way only emails will be saved… do the same with the Search-Mailbox, or you will find an evil behavior… your contacts will fly away from the mail account, because it will be copied an deleted too 😉

  18. Pingback: Moving messages to .pst in Exchange 2010 | B A R R Y

  19. Chris says:

    When we export anything with the new-mailboxexportrequest and view the PST with a third party tool like Kroll ontrack the create date for the message is the date of the collection, the date the pst was exported. If the PST file is accessed with Outlook the dates are the actual dates associated with the messages.

    Has anyone else seen this behavior? If so is there a way to configure the export to report actual dates from the messages instead of the date the export ran?

  20. Magnus says:

    Hi!

    I have used the export with different timeframes without any problems regarding mails. But I have seen holes in the users calendars from this type of export. Do we need to add any extra commands to make sure we have all calendar items and contacts etc?

  21. Clayton A. Lee says:

    Tony,
    Great post and I’ve read through all of the replies and you have been very helpful. I’ve run into a bit of a pickle. I have a user (CEO) whose deleted items are enormous (uses it as a folder). So I’ve exported his deleted items into yearly psts (with contentfilter) using the new-mailboxexportrequest cmdlet successfully. Now the tricky part is how do I delete ONLY those e-mails in the deleteditems folder using the search-mailbox cmdlet with the deletecontent parameter? Is that possible? I can’t see where I am able to use a similar parameter to -includedfolders.

    • Are you looking for an -IncludeFolder parameter so that you can restrict the search only to the “Deleted Items” folder? If so, I believe that you are out of luck. I fear you will have to train your CEO to practice better mailbox management…

      TR

      • Clayton A. Lee says:

        Yeah, thats exactly what I need… training is a nightmare… I think my best bet is to export this year later tonight, empty his deleted items and import it back in. Thanks for the quick reply Tony!

  22. Karsten says:

    Hi Tony,
    we want to do a cross org migration with many mailboxeses and I found the following in the web:

    (Get-Mailbox) | foreach {New-MailboxExportRequest -Mailbox $_.alias -FilePath “\\CNE01b\c$\_pst01\$_.pst”}

    Because it ist cross org it would be better to have Mailadress instead of alias. If i put WindowsEmailAddress instead of the alias I always get soehting like type mismatch. Do you know a way to export the emailadress as part of the filename in a mass export?

    • I bet the issue is that the MailAddress field contains characters that cannot be included in a file name. Hence the type mismatch. You will have to do some formatting to create a “proper” file name before passing it to New-MailboxExportRequest. It might not be a one-line script… but perhaps someone has solved the problem elsewhere on the net? Sorry I can’t help further but I am 12,000 miles away from my lab right now.

      TR

  23. SysIT says:

    Question, is there a way to limit how many mailboxes export at one time, i try this and it seems to want to do 4 at the same time, i would prefer to limit it to 1 or 2 as to not slow down my mail server, as it is an older box.

    • AFAIK, there’s no way to throttle exports in Exchange 2010. The workload management component of Exchange 2013 automatically throttles the work that MRS can do so that will happen for you there. But administrators are in charge of mailbox exports (you have to assign the RBAC role for this explicitly), so shouldn’t you be able to control how exports occur?

      • SysIT says:

        Thanks for the reply Tony,

        i am the Admin myself, i can control it, but since we are a 24/7 operation i was concerned that the export using %100 CPU usage across the board for several hours would cause a slow down in the mail server.

        As it turns out i guess it does manage it well as i had it running over night and through to about mid day and emails were still being processed to everyone, so seems you dont need to limit it, if it were possible.

  24. Peter says:

    I’m going nuts trying to Export using data ranges. I’ve got to the stage where I don’t get any syntax errors (or access errors), but any combination of gt, lt, ge, le and any of ‘ ” {{ () produces a PST of 265KB, and we know what that means.
    The Statistics show that the Export Failed with reason FailedOther, the StartTimestamp and CompletionTimestamp cells are blank. I can export the complete Mailbox so there’s not an over-riding issue.
    I’ve tried UKa dn US date formats, US works, UK results in a “The value nn/nn/nnnn could not be converted to type System.DateTime”
    I’ve turned on the -verbose option and copied&pasted the output to Notepad; I don’t really know what I’m looking for but I can’t see any evidence of ‘fail’ or ‘error’ or even ‘not’.
    Can anyone help me work out what’s going wrong?
    Server is Exchange 2010 SP1, I’m running EMS on a Win7 64-bit SP1 on a Laptop

      • Peter says:

        [PS] C:\>New-MailboxExportRequest -Mailbox -ContentFilter {(Sent -gt ’01/31/2013′)} -Filepath \\\.PST

        is on my laptop, Exchange Trusted Subsystem has Full Control.

        As mentioned, I’ve tried with and without curly and/or rounded brackets, with and without single or double quotes – anything which ‘appears’ to run, fail;s and always with (in the CSV from Statistics) FailOther under StatusDetail

        HTH

        Peter

  25. Peter says:

    Sorry about that garbage! I put stuff inside chevrons without realising what would happen

    [PS] C:\>New-MailboxExportRequest -Mailbox username -ContentFilter {(Sent -ge ’01/31/2013′)} -Filepath \\sharename\filename.pst

  26. Hi,

    I eventually had the time to test this out again. On a Windows 2012 server running Exchange 2013 RTM CU2 (configured with the Ireland locale), I tried exporting with a command like this:

    New-MailboxExportRequest -Mailbox Akers -Filepath “\\ExServer2\Pst\Akers.pst” -Name AkersExp -ContentFilter {(Sent -gt “11/04/2013 23:59”)}

    and everything worked in that all items with a sent date greater than 11/04/2013 23:59 were exported. According to http://technet.microsoft.com/en-us/library/ff601762(v=exchg.141).aspx, the Sent property means “This property returns messages that were sent by the recipient with the specified Sent time stamp”, but the export returned items in the Inbox folder as well, which I did not expect. I’ll report this back to Microsoft to see what they say.

    Can you try gt rather than ge and see what happens. Also, include a time value…

  27. Joshua Thompson says:

    Has anybody tried to do this export using a Journaled mailbox as the source mailbox? When I run the command below it appears as though everything intended exports (copies) to my intended PST. When I open my PST I can see all the Journaled wrapped messages. They each have attachments that are the original message. I can see sender, recipient, date/time, and subject on this original message but no original content. If the original message had attachments I can see those as well . . ..but no original content in the body.

    I have verified all appropriate information DOES show in the Journaled Mailbox.

    New-MailboxExportRequest -ContentFilter “(Received -ge ’09/02/2013 00:00:00′) -and (Received -le ’09/08/2013 23:59:59′)” -Mailbox “JournaledMailbox” -Name “2013-09-02 through 2013-09-08” –FilePath D:\MailArchive\

    • Joshua Thompson says:

      This was fixed with Exchange 2010 SP2 Update 1. Export requests prior to this update left the original message body blank.

  28. I have query when we first export a mailbox to pst it will export all mails when i give second time the same export mailbox command will it overwrite and export whole mailbox or it will only export the mails after the last export like incremental
    Thanks Sir

    • From New-MailboxExportRequest:

      ConflictResolutionOption

      The ConflictResolutionOption parameter specifies the action for the Microsoft Exchange Mailbox Replication service (MRS) to take if there are multiple matching messages in the target. This parameter takes the following values:
      KeepSourceItem
      KeepLatestItem
      KeepAll
      The default value is KeepSourceItem.

      Perhaps this parameter will help you do what you seem to want…

  29. Tom says:

    A solution to the command not properly accepting Australian date format is to change your workstations date format to American.

  30. Frank says:

    Tony
    I have a requirement to export 90 days worth of Inbox, Sent and Delete Items, but I also need the entire Calendar and Contacts. Is it possible to do this in a single request. I sense that if I use -IncludeFolders with -ContentFilter using date ranges that I’m not going to get all the Contacts or Calendar Items required

  31. fernando says:

    [PS] C:\Windows\system32>New-MailboxExportRequest -ContentFilter {(Received -lt ’04/01/2013′) -and (Received -gt ’03/01/2013′)} -Mailbox “user” -Name user1 -FilePath \\server1\temp\user.pst

    Hola, porque la exportación a PST termina con Falla ?. the export PST finish failed ?? .
    Other export pst, for example : New-MailboxExportRequest -Mailbox “user” ContentFilter “#Inbox#” -Name user2 -FilePath \\server1\temp\user2.pst
    The export PST finish OK !!! status = Completed

    because finish “failed” when insert -ContentFilter ?

    thank fernando

  32. Pingback: Export Pst Outlook 2010 Date Range | OutlookRecoveryGuide.org

  33. doubled_it says:

    Thanks very much for the advice, I had some problems with date ranges too as I am in the UK and it wouldn’t accept my date ranges. My findings are posted here:
    http://doubledit.co.uk/2015/03/04/working-with-date-specific-pst-exports-using-powershell/

    • mvcampos says:

      I am working on server with date in Portuguese (Brazil) format. dd/MM/yyyy.

      If I use the filter “(Received -lt ’01/26/2016′)” the ExportRequest is queued and fails after a while with the “ContentFilter is invalid…” error message. If I use “(Received -lt ’26/01/2016′)”, the Export request is not queued and it immediately displays the same error about not being able to convert to System.DateTime.

      I found it weird since it worked for me a few days ago, when I used Jan 12, but now that I recall, I tried Jan 13 and it failed, then I tried the day before (12) and worked. I now realize that it makes sense with your comment on your post: “but never use a number above 12 for the day”

  34. Eugene Kim says:

    Tony,

    I have a few questions could you contact me because I have 150 mailboxes and I require a date range to recovery email from located on a VHD and to be recovered to another VHD. Thank you in advance.

    Eugene Kim

  35. Tom says:

    hi, is it possible to help me create a script to export all items from 1 januari 2015 untill today?
    and will all items be included ? contact / calendar?

    Thx for your support!

  36. mohmmadajan@gmail.com says:

    Hello respectable sir

    how we can delete one month specific guy send/receive email throw shell

  37. hans says:

    Hi Tony

    I am trying to shrink a couple of really large exchange mailboxes using the New-MailboxExportRequest with a content filter and a date range. From what i understand this command only makes a copy of the mailbox items to a pst file. Is there a switch or something to specify that the mail should be moved and not copied or some totally different command to do this? i don’t want to use outlook archiving.

    thanks.

  38. guet says:

    Weird, yesterday this command worked:
    New-MailboxExportRequest -Mailbox USER.NAME -FilePath \\SERVER\Users\Administrator.DOMAIN\Desktop\NAME\NAME.pst -ContentFilter {(received -lt “11/14/2017”)}
    Today I receive a 265kB file and it exports with this status:
    [PS] Get-MailboxExportRequest
    “Name Mailbox Status
    Failed”

  39. guet says:

    If I export without -ContentFilter it works. I used a number higher than 12 for the day BTW.

  40. guet says:

    It works if I set the day date below 13; valid: 11/12/2017

  41. Ozz Lioi says:

    I am getting this error, “the term ‘received’ is not recognized as the name of a cmdlet”.
    I looked throughout this post and seems like I’m the only one here with this issue. Exchange 2010 SP 1.

  42. sphereix says:

    had an absolute nightmare with this so i’m happy to finally post what we used to get it working over in the UK :D… (seemed exchange was still looking for a US date for some reason as well as the full time stamps)

    New-MailboxExportRequest -ContentFilter “(Received -lt ’11/12/2015 23:59:59′) -and (Received -gt ’11/12/2010 00:00:00′)” -isarchive “mailboxalias” -Name jobnameforexport -FilePath \\domain\c$\temp\user.pst

  43. Pingback: [Aside] Exporting Exchange mailboxes to PST (with the ‘ContentFilter’ date format fixed) « rakhesh.com

  44. Poli says:

    The easiest way to solve the date format nightmare and avoid errors is to set first a variable with the date like this: $mydate=”03-31-2020 11:59PM”
    And then, use $mydate wherever you need it, so it will shows like this:

    New-MailboxExportRequest -ContentFilter “(MessageKind -eq ‘Email’) -and ((Received -le $mydate) -and (Sent -le $mydate))” -Mailbox “mailboxname” -FilePath \\Server\share\mailboxname.pst

    This way you will save ONLY emails (nor contacts or calendar appointments…) that was sent and received up tho the date selected. The date will be correctly interpreted by Exchange independently your OS language and regional settings (AFAIK, of course, up to this moment it never failed me)

Leave a reply to guet Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.