Exporting Exchange Mailboxes to PST

An almost mandatory skill for Exchange administrators to understand is how to export mailboxes using the Exchange Management Shell. Maybe you need to export a mailbox to a PST for retention purposes or possibly migrate the mailbox to a different environment. Whatever the reason, knowing this skill from the EMS will simplify the task and allow you to script the work.

First we need to ensure the account that will be doing the export has the correct permissions assigned. To do this,  we will run a command to provide the “Mailbox Import Export” permissions for our admin account. You should be aware that accounts are not assigned this permission by default.
[PS] C:\>New-ManagementRoleAssignment -Role "Mailbox Import Export" -User adminuser
Now that we have the permissions sorted out, we will want to look at the export process. The CMDlet that we will utilize for our export needs is New-MailboxExportRequest. To begin, we’ll look at simply exporting one entire mailbox to a PST:
[PS] C:\>New-MailboxExportRequest -Mailbox usermailbox -FilePath "\\servername\share\file"

It’s important to note that the file path for the export is a network share. The command doesn’t support exporting to a local path. This is because the export process is executed by the CAS role and if you have multiple client access servers, it could be executed by any one of them. So be sure that you set up a share somewhere that all the client access servers can access.

Lets export a mailbox to PST:
[PS] C:\>New-MailboxExportRequest -Mailbox douglas.fargo -FilePath "\\ex13\PSTExport\douglas_fargo.pst"
Now that is export is running we might want to view the status for the export. To do this, run the following command:
[PS] C:\>Get-MailboxExportRequest
More detailed information can be requested by piping the previous command into another PowerShell command:
[PS] C:\>Get-mailboxExportRequest | Get-MailboxExportRequestStatistics | FL
The export requests will stay on the server until you remove them. You can clear them one by one, but I prefer to just clear them all in one shot. So lets remove any requests that are “completed”:
[PS] C:\>Get-MailboxExportRequest | Where {$_.Status -eq "Completed"} | Remove-MailboxExportRequest
To make the command more useful, we can utilize various parameters and filters to target specific messages. For a simple example, we can export all the data from a specific time frame for an account:
[PS] C:\>New-MailboxExportRequest -Mailbox usermailbox -ContentFilter {(Received -ge "startDate") -and (Received -lt "endDate")} -FilePath "\\servername\share\file"
We can also export the messages from a specific folder:
[PS] C:\>New-MailboxExportRequest -Mailbox usermailbox  -SourceRootFolder "Sent Items" -FilePath "\\servername\share\file"

With the different parameters and the content filters, you can have a very powerful command for exporting mailboxes to PST. Here is more info on the CMDlet we are using. In my opinion, the best part is the ability to use the command in a script to perform exports on multiple mailboxes. It cuts down on the amount time it takes to perform these tasks.