How to Bulk Export Mailbox Data from one Exchange Environment and Bulk Import into another

Posted on: 29 June, 2017     Posted by: Kevin    Tags: 

exchange-2013-logo-transparentThere might be instances where an Exchange Administrator will need to export the contents of individual mailboxes to offline files (PST). Starting with Exchange 2010 SP1 we have new set of PowerShell commandlets which can both export and import mailboxes to and from PST files, which have been made much simpler by Exchange 2010 SP1 having its own PST reader and writer.

Whether you are trying to make a backup for a departing employee, to respond to a discovery motion or a compliance request, or you are trying to import data into a test environment, you may from time to time need to either import data from a PST into a mailbox or export a mailbox to a PST.

Here is how you can use the Exchange Management Shell to import a PST into a mailbox or export a mailbox to a PST quickly and efficiently.

Prerequisites for performing Import/Export tasks on mail data

User rights

By default, no user is allowed to Import/Export mailbox data from Exchange. Therefore in order to view or run Import/Export cmdlets in Exchange PowerShell, you must give the require user explicit permission.

In order to provide a user with permission to Import and Export, you must assign the appropriate users/groups the “Mailbox Import Export” Role Based Access Control (RBAC) role.

This can be done one of two ways; through the Exchange Management Shell or Exchange Admin Center.

Exchange Management Shell

Open up the Exchange Management Shell as an administrative user and run:

New-ManagementRoleAssignment -Role “mailbox import export” -User “Admin”

This will add the RBAC role to an individual user.

New-ManagementRoleAssignment -Role “Mailbox Import Export” -SecurityGroup “Mailbox Import-Export

A more scalable solution; this will add the RBAC role to a Security Group. This allows you to simply add users the the security group to give them permission.

Exchange Admin Center

Alternatively this can be done with a few clicks in the Exchange Admin Center which you can get to using:


Simply go to Permissions > Admin Roles and Edit the Organization Management Role.

Add the “Mailbox Import/Export” role to the Roles.

Add the required users/groups to the Members.

Once one of the above commands is run, close and reopen the Exchange Management Shell as one of the users assigned the Import/Export role.  The Import and Export cmdlets will now be available. You can now Export and Import mailboxes from Exchange Management Shell using the new MailboxExportRequest and MailboxImportRequest cmdlets.

Shared Folder

To perform exports and imports, Exchange store and read the data from a network share through a UNC path. The share can be on located on the Exchange server itself, but commands must still reference a UNC path.

Create a new folder to store the PST file from exports and/or to access the PST files for imports.

Share this folder and grant read/write permission to the group “Exchange Trusted Subsystem”.

Exporting Data from an Exchange 2013 Mailbox to PST File using Exchange Admin Center (EAC) GUI

By far the simplest way to export mailbox data to PST for an individual mailbox:

Recipients > Mailboxes

Highlight the mailbox you wish to export to PST

Click on …

Select “Export to a PST file”

Fomr here it’s a simple case of following the Export Wizard. Selecting the contents to export, where to store the exported PST file, you can even specify a mailbox to send a notification email to, notifying when the process has completed.

Whilst this provides a simple method for Exporting, it isn’t very salable and does not provide the same granularity as using the corresponding powershell cmdlets.

Exporting Data from an Exchange 2010 SP1 Mailbox to PST File

Exporting a mailbox will be done by using the “New-MailboxExportRequest” cmdlet.

In order to Export the entire mailbox content to a PST file we need to run the following command:

New-MailboxExportRequest –Mailbox user –FilePath “\\<servername>\Sharename\user.pst”

Note: The -Mailbox and -FilePath parameters are the only required parameters of the cmdlet, but there are other options. Additionally the -FilePath parameter only accepts a UNC path (\\servername\share).

Monitoring Export/Import Requests

The “New-MailboxExportRequest” will trigger the export of the mailbox to a PST file and queue the request. In order to confirm the status of the mailbox export request we can run:


By default, we are going to have three columns: Name, Mailbox and Status for each MailboxExportRequest that has been queued. For more details we can run:

Get-MailboxExportRequest | fl

And all details will be listed for each MailBoxExportRequest. If you have several entries in the list you can always use the mailbox information in the same cmdlet to make life easier. The name of a request, when not specified is going to be the AD location of the mailbox plus MailboxExport (or MailboxImport) for the first one and then incremented by 1:

Get-MailboxExportRequestStatistics "<identity>" |fl

We can also monitor the progress of a MailboxExportRequest by issuing:

Get-MailboxExportRequest | Get-MailboxExportRequestStatistics

In this case where one or more MailboxExportRequest’s has completed successfully, you will want to remove it from the queue. If you wish to remove the completed mailbox export requests from the queue you can run:

Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest

Exporting specific folders from an Exchange 2010 SP1 Mailbox to PST File

Exchange 2010 SP1 also provides you the granularity of Exporting particular data from a Mailbox by using the –IncludeFoldersparameter. For Example, if you want to export only the Inbox of a mailbox then you can use –IncludeFolders parameter specifying the inbox folder.

For exporting only the inbox of a mailbox you have to use following command:

New-MailboxExportRequest –Mailbox “user” –FilePath “\\<servername>\sharename\user.pst> -IncludeFolders “#Inbox#”

Exporting specific data based on word and/or time from a specific Exchange 2010 SP1 mailbox

In some instances you may want to export data containing specific keywords and/or between a specific time, this can be achieved by using the -ContentFilter parameter.

This example exports messages that contain the words “company” and “profit” in the body of the message for the user Tony received before January 1, 2012:

New-MailboxExportRequest -Mailbox Tony -ContentFilter {(body -like "*company*") -and (body -like "*profit*") -and (Received -lt "01/01/2012")} -FilePath "\\<servername>\sharename\Tony_CompanyProfits.pst"

Bulk Export of all Mailboxes

In a lot of cases you will probably want to export all the mailboxes at once to PST. In order to do this you can run the following command to export all mailboxes to a pre-created share named “PST”:

$Export = get-mailbox; $Export|%{$_|New-MailboxExportRequest -FilePath \\localhost\PST\$($_.alias).pst} 

These and many other examples of using this cmdlet can be found on the following Technet page or by issuing the following command:

Get-Help New-MailboxExportRequest -Full

How to Export PST of List of Users from a txt file

$Export = Get-Content C:\Mailbox.txt; $Export|%{$_|New-MailboxExportRequest -FilePath "\\localhost\PST\$($_.alias).pst"}

How to Export All the Mailboxes using a Specified date

Specifying a date lesser than (lt) 01-01-2015:

$Export = Get-Mailbox; $Export|%{$_|New-MailboxExportRequest -ContentFilter {(Received -lt "01/01-2015")} -FilePath file://servername/pst/$($_.alias).pst}

How to Export All the Mailboxes with Specific folders

Specifying Inbox and Sent Items folders:

$Export = Get-Mailbox; $Export|%{$_|New-MailboxExportRequest -InclueFolders "#Sentitems#,"#inbox#" -FilePath file://servername/pst/$($_.alias).pst}

How to Export All the Mailboxes within a Specific Organizational Unit (OU)

$Export = Get-User -OrganizationalUnit “” -Filter “RecipientType -eq ‘UserMailbox'” | Get-Mailbox ; $Export|%{$_|New-MailboxExportRequest -FilePath \\\sharename\$($_.alias).pst}

Importing Data from a PST File to Mailbox

Importing a PST file to a mailbox is very similar to the way you export mailbox to a PST file. In Exchange Server 2010 SP1 importing PST files into mailboxes is performed using Mailbox Import Requests. These are similar to export requests in that they are processed by a Client Access Server (CAS) and likewise, because multiple Client Access Servers can exist in a site there is no way to determine which one will process the request, therefore the PST file to import must be accessible via the UNC path of a shared folder.

As with exporting, the account that is performing the import also needs to be explicitly granted the rights to do so, as no accounts have this right by default (even Organization administrators).

To import a PST file to a mailbox we use the New-MailboxImportRequest cmdlet:

New-MailboxImportRequest –Mailbox User –FilePath \\\sharename\filename.pst

Note: If you already have some data in the mailbox to which you are importing then the above command will simply merge the data with it, it will note remove anything.

You can view the status of the mailbox import request using the Get-MailboxImportRequest cmdlet:


And by piping Get-MailboxImportRequest into Get-MailboxImportRequestStatistics you can also monitor the progress of the import:

Get-MailboxImportRequest | Get-MailboxImportRequestStatistics

If you want to Import the PST file into a specified folder under the mailbox then we can use the following command with a –TargetRootFolder parameter which will create a specific folder and import all the data into it:

New-MailboxImportRequest –Mailbox User –FilePath “\\sharename\filename.pst” -TargetRootFolder “RecoveredFiles”

Bulk Import of Mailboxes

Bulk Import also works very similar to the bulk Export. To import all of the PST files into their respective mailboxes run the following command:

$Import = get-mailbox; $Import|%{$_|New-MailboxImportRequest -FilePath "\\localhost\PST\$($_.alias).pst"}

Note: This assumes that you originally exported the mailboxes using their alias as the pst file name. This is how we Bulk Exported above.

Note: By Default, the import checks for the duplication of items and does not copy the data from the .pst file into the mailbox if matching items exist in the target mailbox.

Import and Export Request Statistics

With large mailboxes, the import and export requests may take a while to complete. If you need to view the status of an import or export request you can use the following commands (Test is the mailbox alias):

Get-MailboxExportRequestStatistics -Identity Test\MailboxExport

Get-MailboxImportRequestStatistics -Identity Test\MailboxImport

More examples and detailed information can be found on the technet for Get-MailboxImportRequestStatistics and Get-MailboxExportRequestStatistics cmdlets.

Or by issuing the following commands in EMS:

Get-Help Get-MailboxImportRequestStatistics -Full

Get-Help Get-MailboxExportRequestStatistics -Full

Completing Mailbox Import/Export Requests

When a mailbox import request is completed it remains on the server until it is removed by an administrator using Remove-MailboxImportRequest.

To see all of the completed Mailbox Import/Export Requests you can run:

Get-MailboxImportRequest | where {$_.status -eq "Completed"}

And to clear all completed mailbox import requests from Exchange run the following command:

Get-MailboxImportRequest | where {$_.status -eq "Completed"} | Remove-MailboxImportRequest


For more information on the New-MailboxImportRequest cmdlet for Exchange 2010 click here.

For more information on the New-MailboxImportRequest cmdlet for Exchange 2013 click here.

For more information on the Removing a mailbox export request for Exchange Server 2010 click here.

For more information on the Get-MailboxImportRequestStatistics cmdlet for Exchange Server 2010 click here.

For more information on the Get-MailboxExportRequestStatistics cmdlet for Exchange Server 2010 click here.