[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Export Mailbox to PST in Exchange 2010 in Bulk

Posted on 2014-08-29
Medium Priority
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 username@domain.com –SearchQuery "Sent:<$('12/31/2010')" –DeleteContent

Thanks for looking and thanks in advance!!
Question by:eshiram
  • 3
  • 2
LVL 29

Expert Comment

ID: 40293376
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

ID: 40298476
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 29

Accepted Solution

becraig earned 2000 total points
ID: 40298939
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

ID: 40306213
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 29

Assisted Solution

becraig earned 2000 total points
ID: 40306950
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


Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
Exchange administrators are always vigilant about Exchange crashes and disasters that are possible any time. It is quite essential to identify the symptoms of a possible Exchange issue and be prepared with a proper recovery plan. There are multiple…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Suggested Courses

872 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