Information
Total Authors: 15
Total Articles: 40
Exporting mailboxes can be useful when an employee or user leaves the workplace. You may want to archive all of the files on a fileserver and delete the old mailbox. Here I will give you the commands and resources to export the mailbox to a PST and to know what to expect before you run into an error.
Environment Preparation
Exchange: Exchange doesn't have the PST exporting command built in until SP1, so you should upgrade Exchange to SP1 or higher.
Computer running the export command: This computer does not have to be the Exchange server, but it does need a few items. Make sure you have these tools installed before you begin:
Export-Mailbox –Identity <mailboxUser> -PSTFolderPath <pathToSavePST>Example:
Export-Mailbox –Identity user.name -PSTFolderPath C:\Temp
You may get an error stating the following:
Error occurred in the step: Approving object. An unknown error has o
ccurred., error code: -2147221241
This means that the MAPI driver that is included in the client computer (one doing the export) might be bad and needs to be fixed. In the shell run this command:
fixmapi
Now, rerun the Export-Mailbox command.
Export-Mailbox –Identity user.name -PSTFolderPath C:\Temp
You may see a new error, this is most likely related to permissions.
To get past this you can run this command:
Add-MailboxPermission -Identity user.name -User Admin01 -AccessRights FullAccess
Again, rerun your export command.
Export-Mailbox –Identity user.name -PSTFolderPath C:\Temp
You will notice the command working and a new file being created as "C:\Temp\user.name.pst".
Powershell
Now, to run this as a powershell script.
Create a new PS1 file (export-messages.ps1):
# this is the export-messages.ps1 file
# to run it type:
# powershell.exe export-messages.ps1 user.name C:\ExportFolder
if($args.Length -eq 2){
#This will produce errors when it's already been loaded, so the -ea fixes that
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin -ea SilentlyContinue
#This will cause a yellow warning if the account is already in the DACL, just ignore it
Add-MailboxPermission -Identity $args[0] -User $env:username -AccessRights FullAccess -Confirm:$false
Export-Mailbox –Identity $args[0] -PSTFolderPath $args[1] -Confirm:$false
}else{
write-host "usage: powershell.exe export-messages.ps1 user.name ""C:\ExportFolder"""
}
Comments (0)