Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / Exchange / How to Import and Export Mailbox to PST in Exchange 2019/2016/2013

March 15, 2024 ExchangePowerShell

How to Import and Export Mailbox to PST in Exchange 2019/2016/2013

In the Exchange Server 2010 SP1 (and newer), special PowerShell cmdlets appeared: New-MailboxImportRequest and New-MailboxExportRequest, which allow you to import or export the contents of the Exchange mailbox from/to PST file. In the previous Exchange versions, to import/export data from Exchange to PST file you had to use third-party utilities (most often, the ExMerge utility was used).

In Exchange 2019, 2016, and 2013,  the Exchange development team continued to develop Exchange cmdlets for importing/exporting to PST files, slightly expanding the functionality and increasing their performance. In this article, we’ll cover typical examples of importing/exporting data from Exchange mailboxes to personal folder files (PST).

Contents:
  • Mailbox Import and Export Permissions in Exchange
  • New-MailboxImportRequest: Importing PST File into Exchange Mailbox
  • New-MailboxExportRequest: Exporting Exchange Mailbox Items to a PST File

Mailbox Import and Export Permissions in Exchange

The RBAC role “Mailbox Import Export” must be assigned to the admin account under which you want to import or export an Exchange mailboxes to PST (by default, even the Exchange administrators don’t have these permissions). You can assign this role to your account using the Exchange Management Shell:
New-ManagementRoleAssignment –Role “Mailbox Import Export” –User fr_exchange_admin
where fr_exchange_admin – is the name of the account that gains the “Mailbox Import Export” role permissions.

Tip. To make the administration easier, the “Mailbox Import Export” role is usually assigned to the AD security group. Later, if this right has to be given to another user, it will be enough to add the user account to this domain group. In this case, the command syntax is a bit different (suppose, the name of the AD group is ExchangeAdmGroup):

New-ManagementRoleAssignment -Role "Mailbox Import Export" -SecurityGroup ExchangeAdmGroup

The same can be done from the EAC (Exchange Admin Center) graphic interface by assigning the Mailbox Import Export to the desired user or group.

"Mailbox Import Export" role in Exchange 2013

After granting RBAC permissions, restart the EAC or Management Shell console.

New-MailboxImportRequest: Importing PST File into Exchange Mailbox

To import a PST file to the Exchange mailbox, you need the following besides the RBAC permissions:

  • The target Exchange mailbox must exist;
  • The PST file must be located on the shared network folder and you have to know the full UNC path to it (don’t forget that the local file on a certain computer can be accessed via its network path like \\PCName111\C$\PST\tstmail.pst);
  • The user performing the import operation must have the NTFS read permission on the network folder with the PST mail archive file.

Use the following command to import the content of a PST file from a shared folder into the user’s mailbox usertest.

New-MailboxImportRequest -Mailbox usetest -FilePath \\HQ-FS01\PST\usetest.pst

When importing into the target box, the contents of existing folders are merged, and new folders are added to the existing mail folder structure.

The contents of the PST file can be imported not into the Exchange mailbox root, but into one of the existing folders of the mailbox (e. g., “Old_mail”). For example, you need to import only the contents of the Inbox folder to the target mailbox folder Old_mail:

New-MailboxImportRequest -Mailbox usetest -FilePath \\HQ-FS01\PST\usetest.pst  -TargetRootFolder "Old_mail" -IncludeFolders "#Inbox#"

Tip. Here is a complete list of the standard folders in the Exchange (Outlook) mailbox:

  • Inbox
  • SentItems
  • DeletedItems
  • Calendar
  • Contacts
  • Drafts
  • Journal
  • Tasks
  • Notes
  • JunkEmail
  • CommunicationHistory
  • Voicemail
  • Fax
  • Conflicts
  • SyncIssues
  • LocalFailures
  • ServerFailures

After running the import command, the import request is queued for processing by the Exchange server (processing is performed on the server with the Client Access Server role). To see the import request queue, run this command:

Get-MailboxImportRequest

Get-MailboxImportRequest in Exchange Server 2013

The import request task status (InProgress, Completed, Queued) for a certain mailbox can be obtained as follows:

Get-MailboxImportRequest mailtst

To get information about the import request status (in percents), run the command below:

Get-MailboxImportRequest | Get-MailboxImportRequestStatistics

Get-MailboxImportRequestStatistics

The completed import requests can be removed from the queue with this command:

Get-MailboxImportRequest -Status Completed | Remove-MailboxImportRequest

Remove-MailboxExportRequest from exchnage queue

To bulk import email items from PST files into multiple user mailboxes, you can use this command (it is assumed that the names of PST files correspond to the names of user mailboxes):

Foreach ($i in (Get-Mailbox)) { New-MailboxImportRequest -Mailbox $i -FilePath "\\HQ-FS01\PST\$($i.Alias).pst" }

If the import process fails, you can get detailed information on its reasons from the report generated as follows:

Get-MailboxImportRequest -Status Failed | Get-MailboxImportRequestStatistics -IncludeReport | Format-List > AllImportReports.txt

In most cases, the import errors occur due to:

  • Logical damage of PST file structure (you can repair Outlook PST files using the scanpst.exe);
  • If the user mailbox size exceeds the specified limit.

You can specify the number of bad items in the PST file that can be skipped during the import. The following command will import the data from the PST file into the Exchange mailbox and skip the first ten failed items before generating an import error:

New-MailboxImportRequest -Mailbox mailtst -FilePath \\HQ-FS01\PST\usetest.pst -BadItemLimit 10

New-MailboxExportRequest: Exporting Exchange Mailbox Items to a PST File

The export of the contents of the Exchange mailbox is similar to import.  To export the contents of the mailbox to a PST file, use the New-MailboxExportRequest cmdlet. To export the mailbox of mailtst user to the shared network folder (this directory has to be created in advance and you must grant read & write permissions on this folder for the Exchange Trusted Subsystem domain group), run the following command:

New-MailboxExportRequest –Mailbox mailtst –FilePath \\HQ-FS01\ExportPST\mailtst.pst

New-MailboxExportRequest: export user mailbox to a pst file

If you have to export to a PST file only email items from a specific folder, e.g., Inbox, the command looks like this:

New-MailboxExportRequest –Mailbox mailtst –FilePath \\HQ-FS01\ExportPST\mailtst.pst -IncludeFolders “#Inbox#”

To exclude a folder from exporting, use the ExcludeFolders parameter. For example, you don’t need to export deleted items to a PST file:

New-MailboxExportRequest –Mailbox mailtst –FilePath \\HQ-FS01\ExportPST\mailtst.pst -ExcludeFolders “#DeletedItems#”

Let’s consider a more complex task: suppose, you have to export all emails received after January, 1, 2019, that contain keywords “Project” and “London”.

New-MailboxExportRequest –Mailbox mailtst –FilePath \\HQFS01\ExportPST\mailtst.pst –ContentFilter {(body –like “*Project*”) –and {body –like “*London*”) –and (Received –lt “01/01/2019”)}

You can also export items only from a specific folder with a search mailbox search results, obtained using the Search-Mailbox cmdlet.

The export task request also is queued on the Exchange server. To see the export task status, run this command:

Get-MailboxExportRequest -Mailbox "mailtst" | Format-List

Get-MailboxExportRequest status

RunspaceId : 3233f0d3-1b4b-4610-b0a2-6f29a543cc54
FilePath : \\HQFS01\ExportPST\mailtst.pst
SourceDatabase : db1
Mailbox :
Name : MailboxExport
RequestGuid : e03de01f-3333-111a-95fa-23faaf97ebf9
RequestQueue : db1
Flags : IntraOrg, Push
BatchName :
Status : Completed
Protect : False
Suspend : False
Direction : Push
RequestStyle : IntraOrg
OrganizationId :
Identity : mailtst\MailboxExport
IsValid : True
ObjectState : New

Don’t forget to periodically clean the completed requests for the export of mailboxes to PST files:

Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest

When exporting the user mailbox to a PST file, the user mailbox contents on the Exchange server are not cleared.

You can export multiple user mailboxes in bulk. Create a CSV text file of the following format:

Username, UNCPathtoPst
t.holland,\\HQFS01\ExportPST\holland.pst
d.orr,\\HQFS01\ExportPST\orr.pst

Run exporting user mailboxes into PST files:

Import-CSV "C:\ps\user_list_export_pst.csv" | ForEach {New-MailboxExportRequest -Mailbox $_.username -FilePath $_.UNCPathtoPst

2 comments
2
Facebook Twitter Google + Pinterest
previous post
Using WMI Filters to Target Group Policies in Active Directory
next post
How Show a Pop-Up or Balloon Notification with PowerShell

Related Reading

View Windows Update History with PowerShell (CMD)

April 30, 2025

Uninstalling Windows Updates via CMD/PowerShell

April 18, 2025

Allowing Ping (ICMP Echo) Responses in Windows Firewall

April 15, 2025

How to Pause (Delay) Update Installation on Windows...

April 11, 2025

How to Write Logs to the Windows Event...

March 3, 2025

2 comments

Ankit Sajwan January 30, 2016 - 12:15 pm

Can I modify script to export psts to their corresponding folder names.foreach ($AllMailboxes in (Get-Mailbox)) { New-MailboxExportRequest -Mailbox $AllMailboxes -FilePath “\\\\$($AllMailboxes.Alias).pst” }

Reply
VennTorrence June 15, 2016 - 12:01 pm

Great solution to export Exchange 2013 data into PST format by using PowerShell commands, and also to importing PST file data into exchange 2013. But sometime import PST file, and export Exchange file data to PST with the help of PowerShell cmdlet is difficult to non-technical users, and the process is also lengthy. So in this situation user can try other solution like converter tool edb.2pst to extract, export exchange mailbox to PST format.

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMware
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 2025
  • How to Write Logs to the Windows Event Viewer from PowerShell/CMD

    March 3, 2025
  • How to Hide (Block) a Specific Windows Update

    February 25, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Get-MessageTrackingLog: Search Message Tracking Logs on Exchange Server
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top