Export Exchange Mailbox to a PST using Powershell

Tonight’s story is one of success.  In my nerdy nature, it brought me great joy.

Recently, I had a request come in to recover a specific email attachment.  From 2014.  Thankfully, the user was smart and sent me the information I needed to begin my search.  I did not tell them that this would be an impossible task because our email backups only go back 60 days, not to mention, we recently migrated them from on-premises Exchange 2010 to Office 365 (Exchange Online).

The Hunt

So I set off on my hunt.  I knew that we still had the Exchange 2010 server up because it was part of their SBS 2011 environment.  The mailbox database was still in tact.  I just had to figure out a way to get to her mailbox and find this very specific email attachment from 2014.

At first I thought that I would set up Outlook on an unused PC and connect to her Exchange mailbox and search it.  This was wrought with other difficulties that I did not want to face that day.

Then I reached the point that every IT technician faces and I went to Google to find the answer.  I knew there had to be a way that I could export the data from the mailbox database into a PST file.  And that’s when I landed on a Technet article. (Thank you Technet!)

The Export

It was awesome to be able to export a mailbox to PST with a powershell command.  I started to enter in the command below:

New-MailboxExportRequest -Mailbox [mailboxuserid] -FilePath "[uncpath]"

But then I realized, that would export the user’s entire mailbox.  That would take a while to do and I don’t want to sift through all the mail.  There is another way!  If you add on another switch to your command like below, you can filter what you choose to export.

New-MailboxExportRequest -Mailbox [mailboxuserid] -ContentFilter {(Subject -like "*Delaware*")} -FilePath "[uncpath]"

This command will export only emails with a Subject line like “Delaware”.  This was extremely helpful in my case because I knew the exact subject line of the email.

Using this method, I was able to successfully recover the email attachment from 2014 and the user ended up happy.  This is a great way to export exchange mailboxes using powershell to a PST file.

Thank you for reading this post.  I hope it helps you someday!