The Exchange Management Shell makes it easy to export mailboxes to a PST file. This short article shows how it works.
In order for mailboxes to be exported (and also imported), the user performing the export must first be assigned an RBAC role; for the Administrator user, this is done with the following command:
New-ManagementRoleAssignment –Role "Mailbox Import Export" –User "Administrator"
After assigning the role, the Exchange Management Shell must be closed and reopened. The CMDLets for export and import are now available.
Export of a single mailbox
The following command can be used to export a single mailbox:
get-mailbox frank | New-MailboxExportRequest -FilePath "\\fwcomex1\d$\Export\frank.pst"
In this example, the mailbox with the alias Frank is exported to \\fwcomex1\d$\Export. The export always takes place to a share, a path such as D:\Export does not work. Only PST can be used as the format. However, PST files can be opened easily with Outlook.
The status of the export can be displayed with the following command:
Get-MailboxExportRequest
More details can be obtained by appending a "| fl". The following command provides the most information, which is also interesting for troubleshooting:
Get-MailboxExportRequest | Get-MailboxExportRequestStatistics | fl
The BadItemLimit is particularly interesting. By default, Exchange aborts the export as soon as a bad item is found in the mailbox. However, the limit for bad items can be adjusted:
get-mailbox frank | New-MailboxExportRequest -FilePath "\\fwcomex1\d$\Export\frank.pst" -BadItemLimit 50
Export of all mailboxes in a database
With a slight modification of the command, all mailboxes in a database can also be exported, for example:
get-mailbox -Database FWDB1 | foreach {New-MailboxExportRequest -Mailbox $_.Alias -FilePath "\\fwcomex1\d$\Export\$_.pst"}
A PST file is then stored in the share for each mailbox:
Export of archive mailboxes
Archive mailboxes can also be exported. The command for an archive of a single user is as follows:
get-mailbox frank -Archive | New-MailboxExportRequest -FilePath "\\fwcomex1\d$\Export\frank_archiv.pst"
All archive mailboxes in a database can be moved with the following command:
get-mailbox -Database FWDB1 -Archive | foreach {New-MailboxExportRequest -Mailbox $_.Alias -FilePath "\\fwcomex1\d$\Export\$_.pst"}
Export shared mailboxes
Shared mailboxes can also be exported; in principle, they are handled in the same way as normal user mailboxes. This means that a shared mailbox can also be exported using the following command:
get-mailbox info | New-MailboxExportRequest -FilePath "\\fwcomex1\d$\Export\info_shared.pst"
All shared mailboxes in a database can be exported with the following command:
get-mailbox -database FWDB1 | where {$_.RecipientTypeDetails -match "SharedMailbox"} | foreach {New-MailboxExportRequest -Mailbox $_.Alias -FilePath "\\fwcomex1\d$\Export\$_.pst"}
Export only certain data from a mailbox
In some cases, it is only necessary to export certain data from a mailbox. For example, only the contacts or only the calendar.
All contacts in a mailbox can be exported with the following command:
get-mailbox frank | New-MailboxExportRequest -FilePath "\\fwcomex1\d$\Export\frank_kontakte.pst" -IncludeFolders Kontakte
The calendar can then be exported as follows:
get-mailbox frank | New-MailboxExportRequest -FilePath "\\fwcomex1\d$\Export\frank_kalender.pst" -IncludeFolders Kalender
Remove ExportRequest
After the data has been exported, the export requests can also be deleted again. All export requests can be removed with the following command:
Get-MailboxExportRequest | Remove-MailboxExportRequest
The command only removes the export request, the PST files remain untouched.