Starting from Exchange 2010 it is possible to import pst files using the New-MailboxImportRequest cmdlet. By default this cmdlet can’t be executed. This is caused by the fact that the New-MailboxImportRequest cmdlet is not a part of the default RBAC groups.
**RBAC
** To create a new group you can use the Exchange Management Shell. This to prevent that specific permissions are assigned per user:
New-RoleGroup 'Mailbox import and export Rights'
Using the cmdlet above we will create a new RBAC group called Mailbox import and export rights. The next step is to add the cmdlet to the RBAC group:
New-ManagementRoleAssignment -Role 'Mailbox Import Export' -SecurityGroup 'Mailbox import and export Rights'
Using the above cmdlet we will add the role _Mailbox Import Export _to the earlier created RBAC group.
Add-RoleGroupMember 'Mailbox import and export Rights' -Member Administrator
As last cmdlet we will add the user administrator to the RBAC group Mailbox import and export Rights. When the cmdlet has been executed you will need to restart the Exchange Management Shell.
**NewMailboxImportRequest
** Before you can import a PST there is one other important prerequisit. The group Exchange Trusted subsystem needs to have permissions to access the share which contains the PST files. When this is not possible you will get the following error Couldn’t connect to target mailbox.
When the last step has been performed we can submit a new import request:
New-MailboxImportRequest -Mailbox Johan -FilePath \\File01\PST\johan.pst
In the example above we will import the PST file called johan.pst from the PST share on the server called File01. The content of the PST will be imported in the mailbox called Johan.
To monitor the process we can use the following cmdlets:
- Get-MailboxImportRequest
- Get-MailboxImportRequestStatistics
**Get-MailboxImportRequest
** This cmdlet will give a default overview of the Mailbox Import Requests which are submitted to Exchange.
For example:
Get-MailboxImportRequest -Identity 'Johan\MailboxImport'
In this case the identity exists of two parts: the name of the mailbox combined with the name of the import request. Using the cmdlet above we will retrieve the status of the import request which has as jobname MailboxImport. The data will be imported in the mailbox called johan.
**Get-MailboxImportRequestStatistics
** Gives a detailed overview of the Mailbox Import Request. This cmdlet can be used in combination with the Get-MailboxImportRequest cmdlet:
Get-MailboxImportRequest | Get-MailboxImportRequestStatistics
When executing the above example you will get a overview of the currently submitted Mailbox Import Requests with additional information. But when needing very detailed information, for example the item count, percentage etc. then you will need to add_ | FL_ to the example above: |
Get-MailboxImportRequest | Get-MailboxImportRequestStatistics | FL
**Couldn’t connect to target mailbox
** As mentioned earlier the error message Couldn’t connect to target mailbox can occur. To troubleshoot this problem you will need to add the -v parameter to the New-MailboxImportRequest cmdlet. In the screenshot below an example can be seen:
In this example both the share permissions and firewall settings where not causing the issue. When searching on the internet you will find several people who are having this issue.
The cause of this issue is: the CAS Array. To solve this problem temporarily you could choose to change the RpcClientAccessServer value temporarily. An other option which might be a easier to use is to create a temporary database and move the mailbox to it. Don’t forget to modify the RpcClientAccessServer value in this case also.
To change the RpcClientAccessServer value we will need to use the following cmdlet:
set-MailboxDatabase MBDBTEMP -RpcClientAccessServer cas01.corp.local
In the example above we will change the RpcClientAccessServer temporarily to one of the CAS Servers.
Don’t forget to restore the old configuration once completed:
set-MailboxDatabase MBDBTEMP -RpcClientAccessServer casarray.corp.local
**Remove-MailboxImportRequest
** Just like a move request an import request won’t be removed automatically. An import request needs to be cleaned up manually. This can be done by using the cmdlet Remove-MailboxImportRequest:
remove-MailboxImportRequest -identity johan\MailboxImport
Using the exampel above we will remove the earlier create import request. When you would like to cleanup multiple import requests use the following cmdlet:
_get-MailboxImportRequest | where {$_.status -eq “completed”} | remove-MailboxImportRequest_ |
Using the example above we will first retrieve all mailbox import requests that are having the status completed. Once found we will remove all those requests.