BULK Export Exchange 2010 mailboxes for PST export using Exchange management shell

I wanted to show you all how to use Exchange Server 2010 Exchange Management Shell to export every mailbox to a PST.  

You can schedule this using Task Manager to allow for a night export of email to individual PST file for easy retrieval of email for users or a one time manual run.  Please use this information at your own risk.  I will not be responsible for mistakes or typos. I do use this script all the time on my own systems and for clients. 

Open the Exchange Management Shell 

Use this command:

foreach ($i in (Get-Mailbox -ResultSize Unlimited)) { New-MailboxExportRequest -Mailbox $i -FilePath “\\server\pstbackup\$($i.Alias).pst” }
 *Please replace “server” with the real server name and “pstbackup” with the real folder sharename.
Once you have 10 successful PSt exports the MailboxExport Request log gets full and you have to run this to clean it up.  Once full the Export will not work anymore.  These commands can also show you if the export was successful or not.

Get-MailboxExportRequest -Status Completed  –> Shows Completed requests
Get-MailboxExportRequest -Status Failed  —> Shows failed requests

This command is how to remove the ExportRequests once full. 

Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest -confirm:$false
Get-MailboxExportRequest -Status Failed | Remove-MailboxExportRequest -confirm:$false

To use this script in a batch file or within the Task Scheduler you must use the PowerShell to call it like the following (where c:\export\export.PST.ps1 is a text file you create with the commands from above):

PowerShell.exe -command “. ‘C:\Program Files\Microsoft\Exchange Server\V14\Bin\RemoteExchange.ps1’; Connect-ExchangeServer -auto; C:\support\exportPST.ps1”