PowerShell Export-Mailbox

PowerShell Export-Mailbox For Exchange 2010

Once you realize that Export-Mailbox is one of the most difficult of PowerShell cmdlets it becomes easier because you take more care with the pre-requisites.  Incidentally, Import-Mailbox and Export-Mailbox in Exchange 2010 replace ExMerge in Exchange 2007.

 ♣

Exchange 2010 Guidelines for Export-Mailbox

If you are new to Export-Mailbox, or troubleshooting why it doesn’t work, then I suggest that you do everything ‘by the book’:

Install Outlook 2010 on the Exchange Server 2010, and run the PowerShell commands on the actual server.  Also remember that unlike Exchange 2007, everything about Exchange 2010 is 64-bit (including the Outlook 2010).

Exchange Server 2010 with no mailboxes.  Perhaps no mailboxes on Exchange server the most bizarre of all the recommendations, but to get Export-Mailbox working, go along with this at least in the beginning.

PowerShell user’s administrator rights.  If you think about it, exporting a mailbox is a responsible task.  Thus to achieve this task make sure you are a member of these exchange groups (later you can see if the Mailbox Import Export role is sufficient) :

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

You can use the Exchange Management Console for this RBAC (Role Based Access Control) assignment, but why not use PowerShell itself?

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

and …..

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

Note A: Logoff, and then logon again to be sure these roles have taken effect.  (Or at least close, and then re-open PowerShell.)

Plan B: If all else fails, try the new Exchange 2010 Archiving and High Availability features.

Possible Tweaks to Export-Mailbox

I would only try these variations once I had initial success.  Perhaps it’s me, but once I get a PowerShell script working then I can extend it’s capabilities in magical ways; however, if it the commands don’t work then I can get into a downward spiral of frustration.

  • Assign the account running Export-Mailbox the lesser right of: Mailbox Import Export role
  • Install the Exchange 2010 Management Tools on a 64-bit Windows 7 machine, and then run the PowerShell commands from there.
  • Relax the ‘no mailbox’ recommendation, try Export-Mailbox on a production server with mailboxes.

The Key Export-Mailbox Parameters

You can use Export-Mailbox to copy (or move) the contents of a mailbox to a specified .pst file, or to a different mailbox that already exists.

-Identity is the first required parameter, it defines the source mailbox.  Decide whether to pipe a Get-Mailbox command into Export-Mailbox, or whether to specify the Display Name, Alias or SMTP address.

-TargetMailbox and TargetFolder are required destination parameters.  Alternatively, you could specify a value for or -PSTFolderPath.

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 1: Basic Export

If all this is new to you, I suggest focusing on -Identity (the source), -TargetMailbox and -TargetFolder (where to copy the data). 

Export-Mailbox -Identity "Mary Evans" -TargetMailbox MaryJo -TargetFolder MaryStuff

Note 1a:  Instead of Export-Mailbox -Identity you could pipe
Get-User "Mary Evans" | Export-Mailbox -TargetMailbox MaryJo – TargetFolder MaryStuff.

Example 2: Exporting to a .PST file

Export-Mailbox -Identity [email protected] -PSTFolderPath C:\PSTFiles\MaryE.pst

Note 2a:  The resulting file would be on the C: drive of the Exchange server, even if you issue the command from a networked machine such as Windows 7.

Example 3: Exporting Particular Emails

Scenario want to export all email in the HR OU containing two specific addresses.

Get-Mailbox -OrganizationalUnit HR | Export-Mailbox -PSTFolderPath C:\PSTFiles -RecipientKeywords "[email protected]", "[email protected]"

Note 3a: Observe how Get-Mailbox substitutes for the -Identity parameter.

Note 3b: This generates multiple .pst files.  One for each user in HR (Human Resources) who has email from psycho or nutter.

Optional Parameters for Export-Mailbox

Once you get the basic command working I recommend you research the family of optional parameters because they will help you filter the data to export, for example, -ContentKeywords or -IncludeFolders.

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

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 2147221233 with Export-Mailbox

The probable cause of above error message is insufficient rights, try a variation of the script below to gain extra rights, in particular change the value of Administrator to your account.

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

Note 5: StatusCode 1056749164 can be caused by the same problem, insufficient rights.

StatusCode 2147467259

Try applying the latest service pack to Exchange Server 2010.

Other Members of the Mailbox Family of Cmdlets

Get-Command -noun Mailbox

More Examples of Mailbox Cmdlets

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

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

Guy Recommends:  A Free Trial of the Network Performance Monitor (NPM)Review of Orion NPM v11.5 v11.5

SolarWinds’ Network Performance Monitor will help you discover what’s happening on your network.  This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.

What I like best is the way NPM suggests solutions to network problems.  Its also has the ability to monitor the health of individual VMware virtual machines.  If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.

Download a free trial of SolarWinds’ Network Performance Monitor

Summary of Export-Mailbox

When you are learning Export-Mailbox make sure that you follow the guidelines before you begin, for example, install Outlook and check the rights for the account that you are using to issue the PowerShell commands.  As you get started focus on the -Identity (source) and the -TargetMailbox (destination) parameters.

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