Export Exchange mailbox data to PST with PowerShell (video guide)

Video’s transcription

Exporting mailboxes to PST is the native Exchange Server’s answer to the question of archiving and a manual migration to another server.

PST files are not very reliable, but they are still widely used. That’s why in this video I show how to export exchange mailbox data to PST.

You can export mailboxes within Outlook, using Exchange Admin Center or with PowerShell. Let’s skip the first two methods and see how to do this with PowerShell.

All cmdlets I use are listed below.

First, I assign the Mailbox Import Export role to my account.

Then, I run the New-MailboxExportRequest cmdlet to export this mailbox to this shared folder.

As a result, I will get a PST file with all items from the specified mailbox. Using additional attributes, I can limit the number of exported items. For example, I can export only the inbox folder, exclude items from the spam and deleted items folders, or export only items which are no older than a month.

Bulk export is just as easy. First, you have to get the list of mailboxes you want to export. You can use Get-Mailbox or Get-ADGroupMember to generate this list and push it to a variable. Then, paste the export script and point it to a shared folder location.

I get a PST file for each mailbox I listed.

Mind that you shouldn’t use PST files for migration or backup purposes if you have any other choice, as this method is severely flawed and prone to error.

Cmdlets used in the video

Assigning Mailbox Import Export role:
New-ManagementRoleAssignment -Role "Mailbox Import Export" -User "<user name or alias>"

Exporting a single mailbox:
New-MailboxExportRequest -Mailbox <user> -FilePath \\<server FQDN>\<shared folder name>\<PST name>.pst

Exporting mailbox items older than a month and with a subject including a keyword:
New-MailboxExportRequest -Mailbox <user> -ContentFilter {Received -lt (get-date).adddays(-30)} -and (Subject -like 'fwd*')} -FilePath \\<server FQDN>\<shared folder name>\<PST name>.pst

Exporting all items except from Junk & Deleted Items:
New-MailboxExportRequest -ExcludeFolders "#JunkEmail#","#DeletedItems#" -Mailbox <user> -FilePath \\<server FQDN>\<shared folder name>\<PST name>.pst

Exporting only Archive:
New-MailboxExportRequest -Mailbox <user> -IsArchive -FilePath \\<server FQDN>\<shared folder name>\<PST name>.pst

Exporting all mailboxes to a specified shared folder:
$AllMailboxes = Get-Mailbox;
$AllMailboxes = $AllMailboxes.SamAccountName;
foreach ($Mailbox in $AllMailboxes) { New-MailboxExportRequest -name "export $Mailbox" -Mailbox $Mailbox -FilePath "\\<server FQDN>\<shared folder name>\$($Mailbox).pst"}

How to return your server’s FQDN and use it for exporting all mailboxes:
$myFQDN=(Get-WmiObject win32_computersystem).DNSHostName+"."+(Get-WmiObject win32_computersystem).Domain
foreach ($Mailbox in $AllMailboxes) { New-MailboxExportRequest -name "export-$Mailbox" -Mailbox $Mailbox -FilePath "\\$myFQDN\share\$($Mailbox.Alias).pst"}

Useful links:

Tools for Exchange Server

Recommended articles

How to migrate from Exchange Server 2016/2019 to Microsoft 365

How to migrate from Exchange Server 2016/2019 to Microsoft 365

Migrating Exchange data to the cloud is not rocket science – explore your options and launch the migration stress-free. As you may already know, Exchange Server 2016 and 2019 have reached end of life and are no longer officially supported by Microsoft. If your organization still uses either of these platforms to manage email, contacts, calendars, and tasks, keep in mind that: Your environment may become vulnerable to newly discovered security threats – Microsoft will no longer provide security updates for Exchange 2016 and 2019 (unless you’ve enrolled in the Extended Security Update program, which ends in October 2026). Your emails may get blocked – Microsoft has started to throttle and block emails sent from unsupported Exchange Server versions to Exchange Online (as I covered in this article). That said, migrating to a supported platform is now the only viable long-term option for keeping your organization’s email environment secure, supported, and fully operational. If your organization wants or needs to keep things on‑premises (and continue using Microsoft’s solutions for that), upgrading to Exchange Server Subscription Edition (SE) is the only path forward. But given Microsoft’s clear preference for its cloud services – evident in the faster rollout of new features and the many security capabilities available exclusively in Microsoft 365 (Office 365) – now is a great time to leave your on‑prem environment behind and migrate to Exchange Online as part of Microsoft 365. While switching over to a new platform might seem like a rough ride, I’ll show you some easy ways to follow when migrating mailboxes from Exchange Server 2016/2019 to Microsoft 365. How to prepare for email migration to Microsoft 365 Before you start the migration process, you need to make sure your environment is ready for the move. For this purpose, you can use this guide in the Microsoft 365 admin center – it will help you connect your organization to Microsoft 365 and integrate your existing user accounts with Microsoft Entra ID. Microsoft also recommends completing the steps below: Set up an SPF record to determine valid email sources for your organization’s Microsoft 365 domain. Set up the Exchange Online Protection service as a means of protection against spam and malware. If you’re behind on updates, make sure to install the latest Cumulative Update (CU). And here is my quick, less obvious Microsoft 365 migration checklist: Verify if your software will work in Microsoft 365 (especially when it comes to server software). Microsoft 365 migration might be the time you learn that there is crucial legacy software that half the company uses and which is hard to replace. Encourage the whole company to clean up projects. It’s much easier to do this before the migration and start fresh. Gather as much information about your on‑premises environment as possible. For example, you might need to recreate access roles and permissions from scratch in the cloud or set up mail flow rules. Without prior research, it will be much more difficult. Verify if you need to migrate service accounts. There can be a lot of them on‑premises and in most cases, you won’t need them after the move. Review mailbox size limits in Exchange Online before migration to see which licenses you’ll need and which mailboxes migh
How to start remote PowerShell session to Exchange or Microsoft 365

How to start remote PowerShell session to Exchange or Microsoft 365

One of many features of the PowerShell command line tool is its ability to connect with and manage the Exchange Server remotely. The procedure described below applies to the classic on-prem Exchange server and to the Microsoft 365/Exchange Online version.
How to migrate Exchange public folders to a shared mailbox in Microsoft 365

How to migrate Exchange public folders to a shared mailbox in Microsoft 365

Still using public folders? Learn how to move them easily to a modern alternative with CodeTwo.

Comments

  1. Dear Adam,

    Required permissions(mailbox import export role) is already set.
    How long it will take for permissions to kick in?
    BTW, I am using exchange online.

    • avatar
      Adam the 32-bit Aardvark says:

      Like I mentioned, this cmdlet is not available for Exchange Online. Unfortunately, it means that the only means of exporting mailboxes to PST is using the eDiscovery tool. In my previous comment, there is a link to an article on how to use eDiscovery for this purpose.

  2. Dear Team,

    New-MailboxExportRequest cmdlet is NOT working and getting the following error:
    New-MailboxExportRequest : The term ‘New-MailboxExportRequest’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
    path was included, verify that the path is correct and try again.

    Could you please add suitable example in video transcript and more information on the option passed to above cmdlet.

    Is there any alternative cmdlet for New-MailboxExportRequest?

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

CodeTwo sp. z o.o. sp. k. is a controller of your personal data.
See our Privacy Policy to learn more.