Exchange 2010 PST backup script

Exchange 2010 SP1

Exchange 2010 is a great email server, however it is not intuitive when its time to backup your user’s mailboxes.  One way to automate it is with some PowerShell script along with a .CSV file including all your mailboxes aliases.

So, do an Exchange 2010 PST Backup Script like the following.

Files you will need to create :

  • Users.csv (text file including all user aliases)
  • export.ps1 (export PowerShell script using Users.csv as input)
  • export.cmd (trigger PowerShell script and connect to your exchange server)


All you need to do is to create a blank file using notepad and rename is to Users.csv.  On the first line, input : Alias, and then 1 alias per line.  It must look like the following screenshot :

notepad users csv



This file is a PowerShell script.  Copy all the following into a new file named Export.ps1 (Users.csv and Export.ps1 must be in same directory)


Get-MailboxExportRequest -status completed | Remove-MailboxExportRequest -confirm:$all

Import-Csv “c:\path\to\Users.csv” | ForEach-Object {

    $PSTPath = “\\sharedcomputer\sharedfolder\pst\” + “.pst”

     New-MailboxExportRequest -Mailbox $_.Alias -FilePath $PSTPath


What you need to edit in the previous script (highlighted blue text) :

  • c:\path\to\Users.csv -> Path to previously created Users.csv file
  • \\sharedcomputer\sharedfolder\pst\ -> You need to create a shared folder with “Everyone” rights to write in it.

Schedule your script to run daily

When everything is saved and fully working (make sure you test it before you automate it), you can create a scheduled task and make it run everyday.



This script will use a generic PowerShell script (named : RemoteExchange.ps1) from your Exchange installation directory and then input previously created export.ps1 PowerShell script.

PowerShell.exe -command “. ‘c:\program files\microsoft\exchange server\v14\bin\RemoteExchange.ps1‘; Connect-ExchangeServer -auto; c:\path\to\export.ps1


You will need to edit the following lines in the previous script according to your paths :

  • c:\program files\microsoft\exchange server\v14\bin\RemoteExchange.ps1
  • c:\path\to\export.ps1


From administrative tools & Task Scheduler, create a new daily task which trigger the following script : export.cmd



All you user’s mailboxes should be secure by now, so there is no need to buy a backup software!
Should you have any questions, feel free to ask!

Spread the love...Share on FacebookShare on Google+Pin on PinterestShare on RedditTweet about this on TwitterEmail this to someone