Export Mailbox to PST in Exchange 2010 in Bulk

Posted on 2014-08-29
Last Modified: 2014-09-16
I have the task of exporting emails for all mailboxes before a certain date and then to delete those emails from their mailboxes before that date. I first want to have a backup of those emails in a PST file before removing it from their mailboxes completely. For instance, I want to export the entire mailbox of John to a PST from the year 2013 and older. Once that is done, I would like to delete all the emails in his mailbox before 2013 permanently. This needs to be done for everyone on Exchange is there any way to do this in bulk.

I have the two following commands but I want to make sure they do what I need.

The first is to export emails from before a certain date to a PST. However, it says Sent -lt 12/31/2013. But this only looks like its all emails in the Sent folder. I want to export the ENTIRE mailbox before a certain date. The full command that I have is:

New-MailboxExportRequest -ContentFilter {Sent -lt '12/31/2013'} -Mailbox "username" -Name MbxExport -FilePath \\hostname\share\mbx.pst

The second command is to actually remove/delete these emails from the users mailbox. My concern is the same as in the first command, to make sure that the ENTIRE mailbox contents before the specified date is deleted. The command I have is:
Search-Mailbox –SearchQuery "Sent:<$('12/31/2010')" –DeleteContent

Thanks for looking and thanks in advance!!
Question by:eshiram
    LVL 28

    Expert Comment

    your commands need some tweaking here is a nice step through the export:

    Once you are done you can pipe the search-mailbox into delete-content as above.

    I am guessing you want "received" and not sent in your command.

    Author Comment

    Hi Becraig,
    Thanks for the response. In the link you sent me I look at How to Export All the Mailboxes using a Specified date. My question is, does this export the entire mailbox before the specified date or just the items in the Inbox (the items that were received)? I want to export the entire mailbox to PST. Is that possible with one command or do I need to use to commands for sent and received?

    Thanks Again!
    LVL 28

    Accepted Solution

    If you notice in step two:
    $Export|%{$_|New-MailboxExportRequest -InclueFolders "#Sentitems#,"#inbox#" -FilePath file://servername/pst/$($_.alias).pst}

    You specify the folders you need with the -InclueFolders flag.
    More info on the flags for this command:

    I hope this answers your question.

    Author Comment

    That did answer that question so thanks for the answer. However, I chose another command. Below are the two commands that I will run. How do I make that for bulk processing?

    For Exporting:
    New-MailboxExportRequest -ContentFilter {(Received -lt "12/31/2013") -or (Sent -lt "12/31/2013")} -Mailbox "networkadmin" -Name MbxExport_Networkadmin -FilePath \\hostname\PSTExport\networkadmin.pst

    For Deleting:
    Search-Mailbox -Identity “networkadmin” -SearchQuery “received:<12/31/2013 and sent:<12/31/2013" –DeleteContent
    LVL 28

    Assisted Solution

    you just pipe the get-mailbox command into it

    get-mailbox | % {
    New-MailboxExportRequest -ContentFilter {(Received -lt "12/31/2013") -or (Sent -lt "12/31/2013")} -Mailbox $_  -FilePath \\hostname\PSTExport\$_.pst

    Open in new window

    get-mailbox | % {
    Search-Mailbox -Identity  $_ -SearchQuery “received:<12/31/2013 and sent:<12/31/2013" –DeleteContent 

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    "Migrate" an SMTP relay receive connector to a new server using info from an old server.
    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now