Exchange 2010

Export all mailboxes from a Database to pst – Exchange 2010

I have been tasked to export all mailboxes on an Exchange 2010 environment to pst. The reason for this is to provide Mimecast with the mailbox data to ingest into the clients archive that is hosted within Mimecast.

We enable journaling on Exchange but need to ingest all mail that was sent and received before journaling was switched on.

Note that you need to have Exchange 2010 SP1 installed to run the below. The mailbox export request is processed by the CAS server role.
The path to the folder that you export to needs to be an UNC path, pointing to shared local folders won’t work.

  1. Make sure you have enough disk space for all the data that you will be exporting.
  2. Create a folder that you will use to export the pst files to.
  3. Make sure you have read/write permissions on the folder that you created.
  4. Open Exchange Management Shell.
  5. Now you need to give yourself the needed rights to export mailboxes to pst by running the following:  

    New-ManagementRoleAssignment –Role “Mailbox Import Export” –User YourUserName

  6. I had to close the Exchange Management Shell and open it again before I could start an export.
  7. Now run the (copy and paste) below script and replace the text in bold with your environment’s parameters:  

    $mailboxes = Get-Mailbox  -Database “Database Name as displayed in Exchange” -RecipientTypeDetails UserMailbox

    ForEach ($mailbox in $mailboxes) {

      $FilePath = “\\yourservername\driveletter$\pst folder name\” + $mailbox.PrimarySmtpAddress.Local + “@” + $mailbox.PrimarySmtpAddress.Domain + “.pst”

      New-MailboxExportRequest -mailbox $mailbox -FilePath $FilePath -BadItemLimit 10000 -AcceptLargeDataLoss -BatchName “any name you wish” -Name $mailbox.PrimarySmtpAddress.Local}

  8. It might look like the script is not running. Just hit enter. If you see >> then hit enter again. The job will then start and export all mailboxes on the specified database to pst.
  9. If you’d like to check the status of the export then run the below:  

    Get-MailboxExportRequest | Get-MailboxExportRequestStatistics

  10. This will show you the status of each queued MailboxExportRequest.
  11. If you have finished the exports then it’s a good idea to clear the completed requests by running:
    Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest

Tip: If your requests are stuck at 0% then restart the Microsoft Exchange Replication Service.

 I’d like to thank my colleague Sergio for sharing the above script.



Leave a Reply

Your email address will not be published. Required fields are marked *