A feature of Exchange 2010 SP1 was to store “older” emails in a different database and to have that database on a cheaper storage subsystem. Given that Exchage primary mailboxes work very well on slower storage anyway you could well be in the position of needing to move archived content, that is content moved to the archive via a retention policy, back to the primary mailbox.
To do this you need to make use of the Export-Mailbox and Import-Mailbox cmdlets to export the contents of the archive to a PST file and them import the PST file back into the primary mailbox.
This process is broken into two parts. The preparation of the server to do the Export/Import processes and then the cmdlets to move the users.
Preparing the Environment
The account needed to run the Export-Mailbox and Import-Mailbox commands needs to be granted the “Mailbox Import Export” role assignment and you need to create a file share on one of your CAS servers that the Exchange Trusted Subsystem has permission to.
To create the File Share create a folder on one CAS server and share it with Advanced sharing. Ensure that “Exchange Trusted Subsystem” has read and write permissions on the file system and Everyone has full control to the share:
If you give your account modify permissions as well, then you will be able to delete the PST file that gets created at the end of this process when it is no longer needed.
Modify your Exchange account so that you have the Mailbox Import Export” role assignment
New-ManagementRoleAssignment –Role “Mailbox Import Export” –User AD\Administrator
You will need to close and re-open any Exchange Management Shell windows you have open to pick up these permission changes. Then you are ready to begin the process of merging the archive out to PST and then the PST into the primary mailbox.
Merging Archives Back to Primary Mailboxes
This process in brief is to ensure Retention Hold is enabled for the mailbox in question and then to run the cmdlets to do the export followed by the import.
These can all be done from the Exchange Management Shell using the following cmdlets. This will prompt for the username and then turn off Retention Hold, export the mailbox (you will need to change the share to match your environment) and then import the mailbox.
The steps to export the mailbox are as follows:
- $UserToMerge = Read-Host -Prompt “Username of user to merge archive back to primary mailbox?”
- New-MailboxExportRequest -Mailbox $UserToMerge -FilePath “\\CAS-SERVER\ExportImport\$UserToMerge.pst” -IsArchive $True
- Get-MailboxStatistics $UserToMerge -Archive | ft DisplayName,TotalItemSize
- Get-MailboxExportRequestStatistics
The above steps will prompt for the username and then start the export of this users archive folder to the given file share. Exports will take time, and this is dependant upon the size of the archive. Therefore this script will finish with an output of the size of the archive (Get-MailboxStatistics –Archive) and the current status of the export. You can repeat the last command on a regular basis to see when the export is complete or use the following to see the percentage complete status:
Once the export is complete the export request can be removed:
You now have a PST file that is a copy of the data found in the users archive. To import this data back into the primary mailbox you need to run the following command:
- New-MailboxImportRequest –Mailbox $UserToMerge -FilePath \\CAS-SERVER\ExportImport\$UserToMerge.pst
- Get-MailboxImportRequest | Get-MailboxImportRequestStatistics
As with the export, the last line allows for you to view the current status of the import.
Once the import is finished the following command will clean up the import requests:
And don’t forget to delete the PST files and remove the archive for the user as well – as the PST is extra to requirements now, and the archive contains content that is replicated to the primary mailbox. If you ever turn the archive back on again then you need to have a new archive rather than using the old one.
To remove a users archive and delete the PST (remembering to change the path shown here) run the following:
- Disable-Mailbox $UserToMerge -Archive -Confirm:$false
- Del \\CAS-SERVER\ExportImport\$UserToMerge.pst
Finally, its possible to save all these commands to two PS1 files (one for the export commands and one for the import ones) to make the repeating of this for other users easier. Or, take a look at Steve Goodman’s blog on Exporting Mailboxes to assist you in writing a script to do this process in bulk.
Leave a Reply