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

Exporting mailboxes to PST is a well known workaround for backup, archiving and migration of Exchange mailboxes. The video below shows all the steps required to export emails, contacts, calendars and other mailbox items to a Personal Storage Table (PST) files.

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. You can learn more on migration and backup with PST files by clicking this link.

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:

4 thoughts on “Export Exchange mailbox data to PST with PowerShell (video guide)


  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.

    • 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>

*

*