Exporting a mailbox from an Exchange server is sometimes easier to connect via an Outlook client and running an export from the menu. But that, like the import procedure in the previous article, is not simple when you want to export a whole load of them. To do this, you can use some simple Powershell commands.

In the example below, we will export the mailbox for our user Joe and drop it out to a directory on the server that we can pickup the PST later.

New-MailboxExportRequest -Mailbox JoeUser@domain.com -FilePath \\EXCH01\e$\PSTimport\JoeUser.PST

To make things more interesting, you can add some extra parameters to make the export a bit more granular. So in the example below we can export messages that have ‘finance’ or ‘money’ in the body and also received before Jan 01 2017.

New-MailboxExportRequest -Mailbox JoeUser@domain.com -ContentFilter {(body -like “*finance*”) -and (body -like “*money*”) -and (Received -lt “01/01/2017”)} -FilePath \\EXCH01\e$\PSTimport\JoeUser.PST

Further to that, we can export particular folders, or exclude particular folders. Try out these two examples. The first includes the folder ‘Inbox’ and therefore will only export the Inbox. The second excludes the Calendar. If you want to include or exclude multiple folders, just add them in succession with a comma. For example -IncludeFolder “#Inbox#”,”#Calendar#”

New-MailboxExportRequest -Mailbox JoeUser@domain.com -FilePath \\EXCH01\e$\PSTimport\JoeUser.PST -IncludeFolders “#Inbox#”

New-MailboxExportRequest -Mailbox JoeUser@domain.com -FilePath \\EXCH01\e$\PSTimport\JoeUser.PST -ExcludeFolders “#Calendar#”

You can have multiple export requests running at the same time. To view what is running and see the status you can use the following commands.

Get-MailboxExportRequest | Get-MailboxExportRequestStatistics | ft

This will give you the full report on everything that is going on. Once a Mailbox export is completed, you can remove them from the system with this command

Get-MailboxExportRequest -status Completed | remove-mailboxexportrequest

 

Mark Rochester

Mark Rochester

Mark is currently a Technical Design Architect for Office 365, working at Dell. His projects consist of large Enterprise implementations of Exchange Online, Azure AD, OneDrive, Skype for Business/Teams.