Export multiple mailboxes with a powershell script

Need to take a copy of multiple mailboxes? I’ve had to do this in the past for various reasons such as audit/investigations etc. You’ll need to create a .csv file with the list of mailboxes you want to export. Then save the script below in a .ps1 file and store it in the same location as the .csv. You can then simply open Powershell and execute the script.

$Date = Get-Date -format “yyyyMMdd”

foreach ($user in (Import-CSV “export-mailboxusers.csv”)) { Export-Mailbox “$($user.Username)” -PSTFolderPath “M:\MailboxBackups\$($user.Username)_$($Date)_Mailbox.pst” -Confirm:$false }

This will work through the csv file and export the mailbox to the path specified (M:\Mailboxbackups in this example). The name of the file is formed from the mailbox name, date and the word mailbox i.e. Peter Egerton_20110802_Mailbox.pst. The date format can be amended as required in the first line.