Share via


Export mailboxes to PST in different ways using Powershell

Most of the administrators run bulk export of mailboxes to PST using this command:

foreach ($i in (Get-Mailbox)) { New-MailboxExportRequest -Mailbox $i -FilePath "\\UNCPATH\$($i.Alias).pst"} 

If your server resources are not sufficient to do the export your server may restart automatically. As a workaround, the below mentioned commands will help you to export to PST without an Exchange Server Service restart/outage by doing a mailbox export one by one.
 

Export mailboxes one by one to same folder

This command will check every three minutes if the current export request is completed or not.  You can change the value based on your mailbox sizes. It will export to \Backupserver\PSTs as PSTs with the alias as the file name. For example, a user with alias jsmith will be exported to \Backupserver\PSTs as jsmith.pst

The below command will export one mailbox at a time. It will check every three minutes.

foreach ($i in (Get-Mailbox)) { New-MailboxExportRequest -Mailbox $i -FilePath "file://backupserver/PSTs/$($i.Alias).pst" -baditemlimit 50 -acceptlargedataloss ;while ((Get-MailboxExportRequest -mailbox $i | ? {$_.Status -eq “Queued” -or $_.Status -eq “InProgress”})) { sleep 180 } }          

Export mailboxes one by one to different folders

Use this command if you want to export to multiple folders. For example, if you have three users with these alias jsmith, Joe and James. You can export to same as below. 
\Backupserver\PSTs\jsmith\jsmith.pst
\Backupserver\PSTs\joe\Joe.pst
\Backupserver\PSTs\james\james.pst

The below command will export one mailbox at a time and will export to the corresponding folders.

foreach ($i in (Get-Mailbox)) { New-MailboxExportRequest -Mailbox $i -FilePath "\\Backupserver\PSTs\$($i.Alias)\$($i.Alias).pst" -baditemlimit 50 -acceptlargedataloss ;while ((Get-MailboxExportRequest -mailbox $i | ? {$_.Status -eq “Queued” -or $_.Status -eq “InProgress”})) { sleep 180 } }