Import PST files using Exchange PowerShell

If we want to import PST files into an Exchange mailbox, we can use the PowerShell CMDlet New-MailboxImportRequest. The PST files that we want to import must be available through a file share, because the CMDlets only accept UNC paths. To import a PST file, we use the following command:

To show this in a real example:

With this command we import the complete contents of the PST file. However, If we use the -verbose option, we will get more information during the import and it helps to find errors faster.

If we receive an error, we can use the Get-ManagementRoleAssignment -RoleAssignee <group or user> command to verify that the user with whom we are running the command has the Mailbox Import Export rights. In addition, the appropriate destination mailbox must exist. We can verify this behavior by using the get-mailbox -Identity <name> command.

With the command get-mailbox -identity <name> | get-mailboxpermission we can verify that we have sufficient rights on the mailbox. The two CMDlets Get-MailboxImportRequest and Get-MailboxImportRequestStatistics provide real-time information about import processes. With these CMDlets we can also use pipes to get more detailed information, like the current status of an import request , its progress in percent and even to get a complete report for a request.

With this, you can easily build a “do…until” loop which waits until the import request has completed and then executes further actions.

In the following example, the do until loop checks and shows the current status of a request every 5 seconds and will send a notification e-mail, including the request report once it has completed.

After an import request has been completed, we need to delete the entry of this import request. To do so, we use the CMDlet Remove-MailboxImportRequest

By the way, in addition to the ability to import a complete PST file, we can also select only individual folders to be imported. This is done by using the -IncludeFolders parameter. Only the specified folders will be imported and all other folders will be ignored from the import. Following, the complete command.

If we want to import all folders and omit individual ones, we can use the -ExcludeFolders option. With the option -ExcludeDumpster we exclude the recycle bin from the import.

However, we can also specify the destination folder in the mailbox where the CMDlet should import the data:

If the specified folder is not present inside of the mailbox, it will automatically be created by the CMDlet. The IsArchive switch will make the wizard import the PST file into the user’s archive.

 

 

Photo by Erda Estremera on Unsplash

Drago is a Microsoft professional for Office 365, Microsoft Exchange, PowerShell and Cloud services. He works as senior System Engineer and Consultant in a leading swiss IT company and CSP. He is also a Trainer for Microsoft Cloud services and Web 2.0 in swiss schools.

Leave a Reply

Your email address will not be published. Required fields are marked *