Export and Import mailboxes in Exchange 2010 SP1

Ever since Exchange 5.5 I have been longing for an easy way to import/export mailboxes to and from PST. I have to admit that Exmerge was a pretty decent tool back then, however, although it did work, I was very disappointed by the requirements of import-mailbox export-mailbox on Exchange 2007, and I prefer to forget the frustration of using these commands with Exchange 2010 RTM.
I can happily say that all my problems are now quickly forgotten after the release of Exchange 2010 SP1 and the new commands New-MailboxImportRequest and New-MailboxExportRequest.

Prerequisites and permissions considerations

I am happy to say that installing Outlook on the server is no longer a requirement to export/import mailboxes and this, for me, was great news!
If you rush things and directly try to run New-MailboxImportRequest cmdlet it will fail with the following error, this is because, by default, no one is assigned the permission to Import and Export mailboxes.
“The term ‘New-MailboxImportRequest’ is not recognized as the name of a cmdlet”

001

For this reason we will start by creating a security group called “Mailbox Support” and assign to it the needed permissions to import – export mailboxes.
N.B.: Note that “Mailbox Support” should be a universal security group for this to work
002

To enable this group to Export-Import mailboxes we need to assign it “Mailbox Import Export” role by running the following cmdlet from Exchange Management Shell (EMS). This powershell command should be familiar for anyone who already tried to import-export mailboxes on Exchange 2010 RTM, in that case there is no need to run it again.

New-ManagementRoleAssignment -Name "Import Export Mailbox Admins" -SecurityGroup "Mailbox Support" -Role "Mailbox Import Export"

003

You should also note that

  • The Import/Export operation can only happen to/from network shares using UNC Paths it cannot be done on local drives
  • The “Exchange Trusted Subsystem” group should be granted read/write permission to the this shared location

Exporting the mailbox to PST

We are now ready to export our first mailbox to a PST file, we can do this by running

New-MailboxExportRequest -Mailbox jdoe -FilePath \\172.19.0.75\c$\jdoe.pst

You can append the –IsArchive parameter to export a user’s archive

004

You can check on the status of the export by using the Get-MailboxExportRequest cmdlet, this command will just show the status Queued, InProgress, Suspended, Completed.

005

More details can be obtained by running the Get-MailboxExportRequestStatistics cmdlet

006

Now, with time, the Get-MailboxExportRequests will start returning a lot of entries, these can be cleared by using the Remove-MailboxExportRequest

007

The table below summarizes all cmdlets available for the Mailbox Export Request

Cmdlet Description
New-MailboxExportRequest Start an export operation from a mailbox to a PST
Get-MailboxExportRequest View mailbox export details
Set-MailboxExportRequest Change the options of an export request
Suspend-MailboxExportRequest Suspend an export request
Resume-MailboxExportRequest Resume a suspended export request
Remove-MailboxExportRequest Remove an export request
Get-MailboxExportRequestStatistics View a more detailed set of export stats

Importing from PST

Now that we have gone over the export process I will cover the import process. In short, the procedure is rather similar to the export one but using MailboxImportRequest cmdlets.
Of course all the prerequisites and permissions covered previously still apply here, so if you are just looking for the import process make sure to read the “Prerequisites and permissions considerations” section above.
Assuming we need to import a PST file called JDoe.pst to John Doe’s mailbox the cmdlet will look as follows

New-MailboxImportRequest -Mailbox jdoe -FilePath \\172.19.0.75\c$\jdoe.pst

008

Just like when exporting, adding the –IsArchive parameter will import the PST directly to the online archive of this user as show in the figure below

009

Another parameter worth noting is the –TargetRootFolder that will import the PST in a separate hierarchy instead of directly in the user’s mailbox/archive. Below is the result of running the following command

New-MailboxImportRequest -Mailbox jdoe -FilePath \\172.19.0.75\c$\jdoe.pst -TargetRootFolder Recovery

010

To get the status of the Mailbox Import Request the Get-MailboxImportRequest cmdlet is used. This will return the status of the request if it is Completed, Queued, InProgress or Suspended.

011

More details about the request can be returned, like the percentage of the progress, using the Get-MailboxImportRequestStatistics cmdlet

012

Once you have done importing orphaned Mailbox Import Requests can be removed by running the Remove-MailboxImportRequest cmdlet

013

One last thing I’d like to share with you today is a small batch import script. This script will simply import all PST files in a corresponding shared location to their corresponding mailbox provided that the PST filename is the same as the mailbox alias of the user it corresponds to

Foreach ($file in dir \\172.19.0.75\psts\*.pst) {New-MailboxImportRequest –Mailbox $file.BaseName –FilePath $file.FullName}

014

The table below summarizes all cmdlets available for the Mailbox Import Request

Cmdlet Description
New-MailboxImportRequest Start an import operation from a PST to a mailbox
Get-MailboxImportRequest View mailbox import details
Set-MailboxImportRequest Change the options of an import request
Suspend-MailboxImportRequest Suspend an import request
Resume-MailboxImportRequest Resume a suspended import request
Remove-MailboxImportRequest Remove an import request
Get-MailboxImportRequestStatistics View a more detailed set of import stats

Conclusion

MailboxImportRequest and MailboxExportRequest are, for me, two key features in Exchange 2010 SP1. I have already used them to migrate a few hundred users’ archives from PSTs to their Online Archive mailbox and planning to migrate quite a few more in the next few months.
The purpose of this article was to share with you what I have learned about these commands till today, and hope it will save you time and effort when you will need them.

I have been working in IT consultancy and solution integration since 1998 and I consider myself lucky to be, one in a few, making a living out of my passion. I am also member of the famous Experts Exchange (profile here) online community where I try my best to share what I have learned along the road.

Posted in Messaging & Collaboration Tagged with: , ,
10 comments on “Export and Import mailboxes in Exchange 2010 SP1
  1. Guest says:

    Ok, I am trying to follow this, I created New Object – Group (step 1) then I ran “New-ManagementRoleAssignment” command (from EMS). I closed EMS and re-opened it.
    But I still get “The term 'New-MailboxImportRequest' is not recognized as the name of a cmdlet”.
    What else I could be missing? I did not reboot the server.

  2. Cmbtrok says:

    for me, the command worked as follows (I used -isarchive to import in online archive, and imported to a user called test):
    new-mailboximportrequest -Isarchive -filepath \<computername>usernametest.pst -mailbox test</computername>

    • Cmbtrok says:

      sorry it is:
      new-mailboximportrequest -Isarchive -filepath \<computername>usernametest.pst -mailbox test</computername>

  3. Ivo says:

    Hy,
    Do you know if there is any possibility to use the New-MailboxImportRequest Cmdlet in Exchange 2010 Hosting Mode? Because there is no -organization parameter, i get always the error “Couldn't connect to the target mailbox.”.
    In the Get- Command of the same Cmdlet, the -organization parameter exists…?
    Thank you in advance.
    Greetings, Ivo

    • bp says:

      There are a lot of commands that are missing the -organization parameter. To get around that I use Get-Mailbox and then pipe the result to whatever command I’m trying to use that is missing the -organization parameter.

      In this case an example would be:

      Get-Mailbox [email protected]:twitter .com -organization DoleCorp | New-MailboxImportRequest -FilePath \serverc$bob.pst

      Note that you omit the -Identity parameter in the second command since that is what is passed form the Get-Mailbox command.

  4. Sro says:

    Great Post!  Thanks.  Is there a way to globally export all the mailboxes located within an entire exchange mailbox database to individual *.pst files for backup purposes?

    • PC says:

      foreach ($i in (Get-Mailbox | Where {$_.ExchangeVersion.ExchangeBuild.Major -eq 14})) { New-MailboxExportRequest -Mailbox $i -FilePath “\ogaex1pst$($i.Alias).pst” }

  5. Beginer in exchnage says:

    hELLO GUYS
    Need to perform a search in the server name “xyz”
    I am looking for all the emails on that server which contain a name “john smith” in the body of the email, I want to avoid the emails with the 4 subject lines in my search “sub1” “sub2” “sub3” “sub4”
    And then I want to export them to a .pst file on a remote location.

    Can you help me with the cmd its giving me hard time now; i am beginer in exchnage so not that good with shell and all 🙂

Leave a Reply to akhater Cancel reply

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

*