The New-MailboxImportRequest and New-MailboxExportRequest cmdlets are used on Exchange Server to export Exchange mailbox to PST file. These PowerShell cmdlets firstly appeared on Exchange Server 2010 SP3 and now available in all recent Exchange versions (including Exchange Online). Let’s take a look at how to export all items from Exchange user’s mailbox to a PST file.
Hint. All Exchange commands need to be executed not in a regular PowerShell console, but in the Exchange Management Shell. You can run it with an EMS shortcut or import this module into your current PS session.
In order to grant account permissions to import/export content of the user’s mailbox, you need to add a specific RBAC “Mailbox Import Export” role to the user or group.
In most cases, it’s better to assign this role to a domain security group. First, create a security group named adm_ExchangeImportExport in Active Directory:
New-ADGroup -Path "OU=Groups,OU=Enterprise,DC=theitbros,DC=com" -Name "adm_ExchangeImportExport" -GroupScope Universal -GroupCategory Security
Add the user accounts you want to grant Exchange export/import permissions to:
Add-ADGroupMember adm_ExchangeImportExport -Members adminstrator,j.brion,m.murphy
Now you can assign the Exchange role to this group:
New-ManagementRoleAssignment -Role "Mailbox Import Export" -SecurityGroup adm_ExchangeImportExport
Then you need to create a shared folder that will be used to save the PST files. Create a shared network folder on any Windows Server and make sure you granted the Read + Modify NTFS permissions to the Exchange Trusted Subsystem group.
To export the entire content of a single user’s mailbox to a separate PST file, you need to specify the username and the UNC path to the shared folder in which you want to place the file:
New-MailboxExportRequest -Mailbox j.brion -FilePath \\fr-srv01\Exchange\PST\j.brion.pst
It is possible to export only a specific folder from the user mailbox. The following command imports only email items from the Inbox to PST:
New-MailboxExportRequest –Mailbox j.brion –FilePath \\fr-srv01\Exchange\PST\j.brion.pst -IncludeFolders “#Inbox#”
Hint. Here is a complete list of the default Exchange mailbox folders. You can use any of them in your commands:
- Inbox
- SentItems
- DeletedItems
- Calendar
- Contacts
- Drafts
- Journal
- Tasks
- Notes
- JunkEmail
- CommunicationHistory
- Voicemail
- Fax
- Conflicts
- SyncIssues
- LocalFailures
- ServerFailures
You can use different search filters to select and export only specific items from the mailbox:
New-MailboxExportRequest –Mailbox j.brion –ContentFilter {(All –like “contract”) –or (All –like “password”)} –FilePath \\fr-srv01\Exchange\PST\j.brion.pst
You can export to PST files all user mailboxes at once. A separate PST file will be created for each mailbox:
Foreach ($i in (Get-Mailbox)) { New-MailboxExportRequest -Mailbox $i -FilePath \\fr-srv01\Exchange\PST\$($i.Alias).pst" }
The export operation of the mailbox to a PST file is performed by the Exchange servers in the background. To get information about the current export operation progress, run:
Get-MailboxExportRequest j.brion
You can also display the mailbox export status in percents (PercentComplete):
Get-MailboxExportRequest | Get-MailboxExportRequestStatistics
Wait until PercentComplete is 100 and the status changes to Completed.
You can pause or resume any mailbox export request with the Suspend-MailboxExportRequest and Resume-MailboxExportRequest cmdlets.
After the export of the mailbox is finished, you need to clear all completed export requests from the Exchange:
Get-MailboxImportRequest -Status Completed | Remove-MailboxImportRequest
- How to Create a GUI for PowerShell Scripts? - April 9, 2021
- How to Configure Radius Server on Windows Server 2016? - April 8, 2021
- How to Check Airpod Battery on Android? - April 7, 2021