Exchange 2007/2010: Export mailboxes with PowerShell
Export mailboxes to PST in bulk
Most of the administrators run bulk export of mailboxes to PST using the command
foreach ($i in (Get-Mailbox))
{
New-MailboxExportRequest -Mailbox $i -FilePath "\\UNCPATH\$($i.Alias).pst"
}
If your server resources not sufficient to do the export your server may restart automatically. As a workaround below mentioned commands will help you to export to PST without 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 3 minutes that current export request is completed or no. You can change the value based on your mailbox sizes.
It will export to \Backupserver\PSTs as PSTs with alias as the file name. Example a user with alias jsmith it will be exported to \Backupserver\PSTs as jsmith.pst
Below command will export one mailbox at a time. It will check every 3 minutes
foreach ($i in (Get-Mailbox))
{
New-MailboxExportRequest -Mailbox $i -FilePath "\\Backupserver\PSTs\$($i.Alias).pst" -baditemlimit 50 -acceptlargedataloss ;
while ((Get-MailboxExportRequest -mailbox $i | ? {$_.Status -eq “Queued” -or $_.Status -eq “InProgress”}))
{ sleep 180 }
}
Export malboxes one by one to different folders
If you want to export to multiple folders. For example if you have 3 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
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 }
}