Categories

Archives

Exporting Exchange 2010 Mailbox to PST

Below is an easy script showing how to export a user Mailbox to a .pst file and subsequently how to send an E-mail to specified user with the information of successful (or not) export.

#Create export task and save the pst file to a network share
New-MailboxExportRequest -Mailbox "User1" -BadItemLimit '20' -FilePath "\\mailboxserver\pstexport$\"
 
#Create a loop which is checking if the task has been finished with 100%
$exstat = Get-MailboxExportRequest | Get-MailboxExportRequestStatistics | where {$_.sourceAlias -eq 'User1'}
 
do {Start-Sleep -Seconds 5; $exstat = Get-MailboxExportRequest | Get-MailboxExportRequestStatistics | `
where {$_.sourceAlias -eq 'User1'}}
until ($exstat.percentcomplete -eq '100')
 
#Send a mail to an Administrator with the information that the export has been finished.
Send-MailMessage -To Admin@company.com `
-From pstexport@company.com `
-Subject "PstExport for $exstat finished" `
-Body 'Hello, <BR> The Export for user User1 has been finished and is saved under \\mailboxserver\pstexport$ <BR> Cheers, <BR> Powershell Script' `
-SmtpServer mx.company.com `
-BodyAsHtml

This post is also available in: German, Polish

Comments are closed.