Managing PST Import-Export process in Exchange Server 2013 (Part 2)

by [Published on 19 Dec. 2013 / Last Updated on 19 Dec. 2013]

In this article, the author covers how to import and export PSTs using Exchange Management PowerShell.

If you would like to be notified of when Anderson Patricio releases the next part in this article series please sign up to our MSExchange.org Real Time Article Update newsletter.

If you would like to read the first part in this article series please go to Managing PST Import-Export process in Exchange Server 2013 (Part 1).

Introduction

In our last article we used the EAC (Exchange Admin Center) to export/import PST files using a Shared Folder. In this article we will check the status of previous export/import processes and then go to some advanced configurations that we can do using Exchange Management Shell.

Checking the status of the Import/Export Process

The process to check the Import and Export process using Exchange Management Shell is based on the same concept. We just need to change the cmdlet from *-MailboxExportRequest to *-MailboxImportRequest. So, use this as a reference when checking the following cmdlets.

In order to see what is going on we can run the Get-MailboxExportRequest as shown in Figure 01. By default, we are going to have three columns: name, Mailbox and status.

Image
Figure 01

In order to get more details about the process we can run Get-MailboxExportRequest | fl and all details will be listed as shown in Figure 02.

Image
Figure 02

If you have several entries in the list you can always use the mailbox information in the same cmdlet to make life easier (Figure 03). The name of a request, when not specified is going to be the AD location of the mailbox plus MailboxExport (or MailboxImport) for the first one and then incremented by 1 (one).

Image
Figure 03

In some cases, we need to check the status of the last operation and it can be useful for troubleshooting as well. We can use the same cmdlet that we have been using and adding the switch –report to get the historical information of the previous run, as shown in Figure 04.

Image
Figure 04

Cleaning-up the Requests...

By default, each Mailbox Import/Export request will have the name MailboxExportX, where X is a number starting from 1 to 9 and after that the cmdlet will ask you to name your new requests.

Bear in mind that we are going to focus on the Export process, however you can replace the Export string on all cmdlets below to Import and get the same results.

In order to check the existent requests we can use Get-MailboxExportRequets and a list of all current requests (Name, Mailbox and Status) will be listed as shown in Figure 05.

Image
Figure 05

If you want to remove all Completed requests we can use the cmdlet shown below to remove all existent entries, the same cmdlet in action is shown in Figure 06.

Get-MailboxExportRequest | Where { $_.Status –eq ‘Completed’ } | Remove-MailboxExportRequest –Confirm:$False

Note:
Using –Confirm:$False saves a lot of time because using default values for each request, a confirmation action will be required.

Image
Figure 06

We can also use grid view to help removing requests. Let’s start running the following cmdlet:

Get-MailboxExportRequest | Out-GridView –PassThru | Remove-MailboxExportRequest

The results can be seen in Figure 07, where the administrator can select one or more items from the list and click OK. This will trigger the removal of that item. Pretty cool, isn’t it?

Image
Figure 07

Again the –Confirm:$False is key to avoid getting annoying messages. If we don’t add this parameter, then we have to go back to the PowerShell to confirm the action. In order to avoid this default behavior, add such parameters as shown in Figure 08. By doing that your grid-view experience with removing entries will be much better.

Image
Figure 08

Exporting to PST using Exchange Management Shell

In order to Export to a PST there are only two required parameters: Mailbox and a PST location. If we want just to export the entire content, we can run the cmdlet shown below and the result will be a request being queued as shown in Figure 09.

New-MailboxExportRequest <Mailbox> -FilePath <EXUtil-Shared-Folder-on-Exchange>

Note:
The Mailbox can be an alias, SMTP or Display name.

Image
Figure 09

With Exchange Management Shell, we have several parameters to help us out to perform granular PST exports. A good example is to generate a PST of a couple of mailboxes in the same PST file. This can be easily achieved using Exchange Management Shell. Basically, we just need to run 3 Exports using the same file and we can also create a folder for each source mailbox using the –TargetRootFolder as shown in Figure 10.

Image
Figure 10

The result on the PST will be similar to the one shown in Figure 11.

Image
Figure 11

You may be wondering, how about Archives? Well they are covered by just adding –IsArchive in the cmdlet and the PST generated will have the Archive Mailbox as source instead of the regular user mailbox.

We can also manage folders to be included or excluded by specifying parameters. If you have localized clients you can always use #Inbox# and that will apply for the Inbox in the other language as well, and that also applies to any other default system folder. This way you can use the same script across multiple sites/locations. Here are a couple of interesting parameters that we can add to a New-MailboxExportRequest cmdlet.

  • ExcludeDumpter
    We define if the Recovery Deleted Items will be part of the PST
  • ExcludeFolders
    We can define a list of folders that will be removed from the PST export process.
  • IncludeFolders
    In this parameter we can define which folders will be included in the PST export process.

The last but not least is the –ContentFilter parameter where the administrator can set advanced filters where only messages that match the filter specified will be exported to a PST. With ContentFilter the administrator can filter by time range, recipient, sender, such as date range, sender and recipient, attachment names, participants and so forth.

Importing from PST using Exchange Management Shell

The import process is when data located in a PST file is moved to a mailbox or Archive mailbox in the Exchange Server environment.

Note:
When importing PST files, a good thing to keep in mind is that the cmdlet will import whatever data you have in the PST into the mailbox specified, in other words, there is no validation of the content being imported. It is highly recommended to check the PST and mailbox to avoid wrong data being imported into a mailbox/archive.

The basic cmdlet to import any given PST to a mailbox is described in the following syntax:

New-MailboxImportRequest <mailbox> -FilePath <\\UNCPath\file.pst

A question that keeps coming on the Forums is: how do I restore a PST to an Online Archive mailbox? That can be done using the same –IsArchive parameter, the following syntax can be used:

New-MailboxImportRequest <mailbox> -IsArchive –FilePath <\\UNCPath\folder\file.pst>

The New-MailboxImportRequest also has the same SourceRootFolder, TargetRootFolder, IncludeFolders, and ExcludeFolders parameters like the New-MailboxExportRequest.

If you want to import all PST files from a folder into exchange (make sure that the file name matches the mailbox name) we can use the following cmdlet:

Get-ChildItem *.pst | Select Name,Basename | ForEach { New-MailboxImportRequest $_.BaseName –FilePath (“\\parex13\EXUtil$\” + $_.Name) –TargetRootFolder Restored-Data }

Note:
In Figure 12 the account was on the same server, however we can replace Get-ChildItem *.pst for Get-ChildItem \\server\sharedfolder\*.pst and we will have the same result without logging on the server that has the PSTs locally. 

Image
Figure 12

Conclusion

In this article, we went through the process of using Exchange Management Shell to manage the existent requests and covered also how to import and export requests using some of parameters that are available only when using PowerShell.

If you would like to be notified of when Anderson Patricio releases the next part in this article series please sign up to our MSExchange.org Real Time Article Update newsletter.

If you would like to read the first part in this article series please go to Managing PST Import-Export process in Exchange Server 2013 (Part 1).

Advertisement

Featured Links