PowerShell Import-Mailbox

PowerShell Import-Mailbox From .PST File

PowerShell’s Import-Mailbox will take the contents of a .pst (Personal Storage) file and transfer them into an existing Exchange Server 2010 mailbox.

 ♣

Check the Importer’s Administrator Rights

If you think about it, importing email is a responsible role.  Thus to achieve this task make sure you are a member of these exchange groups:

  • ‘Organization Management role group’
  • ‘Server Management management role group’
    Management management is not a typo!

You could use the Exchange Management Console to assign this RBAC (Role Based Access Control), but I prefer to employ PowerShell itself.

New-ManagementRoleAssignment -Role "Organization Management role" -User Administrator

and…

New-ManagementRoleAssignment -Role "Server Management management role" -User Administrator

Note A: You need close, and then re-open PowerShell for this to work, however, to be sure, I logoff and logon before I try these new roles.

Note B: Once your scripts work, consider assigning the account running Import-Mailbox the lesser rights of: Mailbox Import Export role.

The Key Import-Mailbox Parameters

You can use Import-Mailbox to copy the contents of a .pst file, into an Exchange 2010 mailbox that already exists.

-PSTFolderPath  This parameter could not be more descriptive!  You must tell PowerShell where to find the .pst file.

-Identity is an optional source parameter.  Decide whether to pipe a Get-Mailbox command into Import-Mailbox, or else specify the Display Name, Alias or SMTP address.

Example 1: The Basic Import

To get the script working, focus on Import-Mailbox’s -PSTFolderPath parameter.

Import-Mailbox -Identity "Guy Thomas" -PSTFolderPath C:\Pst\Guy.pst

Note 1a: Instead of the mailbox alias you could use the email address, or even these alternatives: GUID, Domain\Account name, User principal name (UPN) or SMTP address.

Note 1b: Good news:  If a message from the .pst file already exists in the mailbox, Exchange 2010 won’t create a duplicate message. 

Guy Recommends:  SolarWinds’ Free Bulk Mailbox Import ToolFree Download Bulk Mailbox Import Tool

Import users from a spreadsheet, complete with their mailbox.  Just provide a list of the users with the fields in the top row, and save as .csv file.  Then launch this FREE utility, match your Exchange fields with AD’s attributes, click and import the users.  Optionally, you can provide the name of the OU where the new mailboxes will be born.

There are also two bonus tools in the free download, and all 3 have been approved by Microsoft:

  1. Bulk-import new users and mailboxes into Active Directory.
  2. Seek and zap unwanted user accounts.
  3. Find inactive computers.

Download your FREE bulk mailbox import tool.

Example 2: Importing Lots of .PST Files

Take the scenario where you have already exported a bunch of .pst files.  Instead of importing each individually, you could pipe the filenames into Import-Mailbox.

Get-ChildItem C:\Pst | Import-Mailbox

Note 2a:  Another advantage of piping a stream of .pst files is that you don’t need the -Identity parameter in the Import-Mailbox part.

Note 2b:  The imported files needs to be on the C:\pst folder of the Exchange server, even if you issue the command from a networked machine such as Windows 7.

Example 3: Importing Mailboxes from an OU

Get-Mailbox -OrganizationalUnit Scientist | Import-Mailbox -PSTFolderPath C:\SciencePst

Note 3a: Observe how PowerShell lines up the users in the Scientist OU then imports data held in individual .pst files in the C:\SciencePst folder.  Once again, the key parameter is -PSTFolderPath.

Optional Parameters for Import-Mailbox

Now that you have the basic command working I recommend you research the family of optional parameters to filter the data to import, for example, -ContentKeywords or -ExcludeFolders.

Note 4:  See more on PowerShell’s Import-Mailbox.

Troubleshooting Import-Mailbox StatusCodes

Correct 2010 Versions?

  • Strangely, you need to install a 64-bit version of Outlook 2010 on the very server where you are importing.
  • Remember that unlike Exchange 2007, everything about Exchange 2010 is 64-bit. Thus don’t try importing pst files using a 32-bit version of Windows Server 2003. Or a 32-bit Windows 7 client.
  • As expected, you can’t use the Exchange 2010 Import-Mailbox cmdlet to import .pst files to a mailbox on Exchange Server 2007 or earlier.

Free Download of Exchange Monitor from SolarWindsGuy Recommends: The SolarWinds Exchange Monitor

Here is a free tool to monitor your Exchange Server.  Download and install the utility, then inspect your mail queues, monitor the Exchange server’s memory, confirm there is enough disk space, and check the CPU utilization.

This is the real deal – there is no catch.  SolarWinds provides this fully-functioning freebie, as part of their commitment to supporting the network management community.

Free Download of SolarWinds Exchange Monitor

StatusCode Error Messages

StatusCode 2147221219 with Import-Mailbox

The probable cause of StatusCode 2147221219 is insufficient rights, try a variation of this script, in particular change the value of Administrator to your account.

New-ManagementRoleAssignment -Role "Mailbox Import Export role" -User Administrator

Note 5: If you have already tried this get then make sure you have applied SP1 to your Exchange Server 2010.

Other Members of the Mailbox Family of Cmdlets

Get-Command -noun Mailbox

More Examples of Mailbox Cmdlets

  • Disable-Mailbox
  • Enable-Mailbox
  • Export-Mailbox
  • Get-Mailbox -Identity "Guy Thomas" [Good place to start]
  • Move-Mailbox
  • New-Mailbox
  • Move-Mailbox
  • Remove-Mailbox
  • Restore-Mailbox
  • Search-Mailbox
  • Set-Mailbox

Note 6:  See more on PowerShell’s Import-Mailbox.

Summary of Import-Mailbox .Pst

With PowerShell’s Import-Mailbox you can extract the contents of a .pst (Personal Storage) and copy them into an Exchange 2010 mailbox using the -PSTFolderPath parameter.  The only tricky part is making sure that you have the appropriate permissions.  Oh yes, it helps if your Exchange Server 2010 has the latest service pack.

If you like this page then please share it with your friends

 


See more PowerShell Cmdlets for Exchange 2010:

Exchange 2010 Home   • Get-ExchangeServer   • Set-ExchangeServer   • New-SystemMessage   • SP1

Get-Mailbox   • Get-MailboxStatistics   • Connect-Mailbox   • Enable-Mailbox   • Disable-Mailbox

PowerShell Exchange Cmdlets   • Set-Contact    • New-Mailcontact   • Add-MailboxPermission -identity