<

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Import mailboxes from PST into Exchange 2007 using Powershell

Published on
23,223 Points
12,823 Views
9 Endorsements
Last Modified:
Awarded
In Exchange 2003, one of the simplest ways to move mailboxes from one Exchange organisation to another was using exmerge. It was particularly useful for sites using 'Small Business Server' where the level of data and requirements were low.

In Exchange 2007, exmerge is not a supported method for Importing from PST files. The functionality has been naturally replaced with the Import-Mailbox cmdlet.

Prerequisites

Computer running 32-bit version of Microsoft Windows on which you can install the Exchange Management Tools (SP1)  for the entire organization.
Microsoft Outlook 2003 SP2 or higher needs to be installed on the above workstation.
You need to be either Exchange Organisation Administrator (if mailboxes are across multiple servers) or Exchange Server Admin (if mailboxes are all on one server).
For all PSTs you plan to import, you need to have created the mailbox enabled users with associated user 'alias', which is usually the users login name, that needs to match the name of the PST file.
You need to have 'full permissions' to the above mailbox(es) you are importing; however, that will be shown in step #2.


1. Install the Exchange 2007 SP1 Management Tools


**A note on Exchange Management Tools installation pre-requisites**
During testing, I found that Windows 7 already met all the pre-requisites out of the box. However, if you are using an older operating system, you may need to double check you definitely have the necessary setup mentioned in the pre-requisite section.


Log in to the PC which has Outlook 2003 SP2 or higher installed with an appropriate account.

Grab the installation files - Exchange 2007 Management Tools - Choose E2K7SP1EN32.exe from the available options.

Run a 'Custom' install, selecting only the management tools; we do not want to install any other roles on this workstation!  After the install, make sure that you run ALL the same update rollups that have been installed on your organisation's Exchange server(s).  If using SP1, it is important that you install update rollup 9 on this computer now that the Management Tools have been installed.

Rollup Update 9 for Exchange 2007 SP1 can be found here: Update Rollup 9 for Exchange 2007 SP1 - Choose Exchange2007-KB970162-x86-EN.msp from the list.

** A note on account permissions **
If you have tried with an account that does not have the correct Exchange administrator role, once you have fixed the issue by assigning either Exchange Org Admin or Exchange Server Admin, you will need to Logout of the management station and log back in again for this change to take effect.


2. Add Full Access Permissions to the Mailboxes


Next is to add FullAccess to all the mailboxes being imported. This is done using the Add-MailboxPermission cmdlet. I will not go into detail on this cmdlet. Suffice to say that running the following will give the user account 'shaun' FullAccess permission on all mailboxes for a particular mailbox server.

Get-ExchangeServer <servername> | Get-Mailbox | Add-MailboxPermission 
   -User Shaun -AccessRights FullAccess -inheritancetype all

Open in new window

*note: this should be executed as one full command. Multi-line for display only.

After you are done, you may wish to remove these permissions, to do so, use the following command:

Remove-MailboxPermissions -User Shaun -AccessRights FullAccess 
   -inheritancetype all -confirm:$false

Open in new window

*note: this should be executed as one full command. Multi-line for display only.

Of course, if you wish, you can perform this using the GUI:

Open Exchange Management Console
+Recipient Configuration
+Mailbox and select the users
+Manage Full Access Permissions (on the Action pane)
+Use Wizard to add the account granted full access

3. Using the Import-Mailbox cmdlet


Now is time for the Import-Mailbox command. The Import-Mailbox command has a couple of parameters that we are especially interested in.

-Identity

As the name suggests, this is where you specify the mailbox you would like to use for the destination of the import routine.

-PSTFolderPath

This will point the Import routine to look in the path for the PST files we are interested in. If you have only ONE PST file to import for a specific user, you can reference the exact PST file here and it will import the PST file. However be careful that you do not specify an explicit PST file and pipe multiple Mailboxes to the command, otherwise it will import the same PST file for all users which could have some embarrassing results!

-MaxThreads

This is the number of mailboxes to move at any one time. Now, this will largely depend on the resources that you have available. The typical value is 4, and this is normally more or less acceptable for this operation unless you have thousands of mailboxes, then you may want to increase this. Just remember ultimately you will have hardware bottlenecks.

-ValidateOnly

Using this switch is similar to the whatif switch in other cmdlets (and this one in fact). It will not move any data, only highlight if the process is likely to be successful and notify you if there are any issues you need to take care of.  

So once we have the PST file(s) in the PSTFolderPath of our choosing run the command depending on your situation:

Importing a single PST to a single Mailbox:

Import-Mailbox <MAILBOX ALIAS> -PSTFolderPath <PathToFolderContainingPST>

Open in new window

Importing a bunch of PST files to their associated Mailboxes:

Dir C:\PSTFiles\*.pst | Import-Mailbox

Open in new window


Go through ALL mailboxes, and find associated PST and import:

Get-Mailbox | Import-Mailbox -PSTFolderPath <PathToFolderContainingPST>

Open in new window



So as you can see, this routine is all in the preparation of the environment. The actual commands you run to do the Import are small, sweet and efficient. The great thing about using Powershell for this task is that it is so scalable, if you have a situation where there are many PST's you need to import, this will quite happily do the work.


References:

You Had Me At EHLO...
How to Export and Import mailboxes to PST files in Exchange 2007 SP1
http://msexchangeteam.com/archive/2007/04/13/437745.aspx

Import-Mailbox cmdlet Technet reference
http://technet.microsoft.com/en-us/library/bb629586.aspx 

How to Import Mailbox Data Technet reference
http://technet.microsoft.com/en-us/library/bb691363.aspx
9
Comment
3 Comments
LVL 61

Expert Comment

by:Kevin Cross
Good job, Shaun!
Voted yes above.
0
LVL 16

Expert Comment

by:Jon Brelie
Question:

Suppose I have a single PST file that I want to import in the the mailbox of all users in a group.  IE, import the same PST data into multiple mailboxes.  Is there a powershell method to replace <mailbox alias> with <get users from GroupA>?
0
LVL 1

Expert Comment

by:Robinsan Shaw
Well written Method to import mailboxes of PST File format stored in Exchange mailbox. While searching method to directly import Outlook details to Different Exchange Server, find Software know as "Exchange Import" Tool.
The tool supports Exchange 2016, 2013, 2010 and below version. No need of Powershell command now to move mailboxes and also offers an option to import individual section such as "emails, contacts, task and  Calendar" Details without data loss. I import pst file to Exchange 2007 Server with this utiliy and tool doesn't disappoint me
0

Featured Post

OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

Join & Write a Comment

This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Other articles by this author

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month