Powershell – Exchange 2007 Mailbox Cleanup – Exporting Mailboxes Script

exchangeexchange-2007powershellscripting

I have been assigned a task to cleanup our Exchange server by exporting the mailboxes of users who have left the company. We want to keep a copy of the mailbox for 90 days, just in case HR or management needs it later. I have over 130+ mailboxes to export to complete this task.

I see that the only way to export a mailbox to a PST is to use Export-Mailbox cmdlet via the Exchange Management Tools. My question is this: Is there a script where I can do this en mass?? Perhaps past the email adresses into a file and run the script? This would be helpful and cut down the time it would take to complete this task.

Thanks in advance for any suggestions or help!!

Best Answer

Create a CSV with a single column of Exchange aliases. Add a header row at top with "Alias", and change the "E:\DriveForPST\ to point to a folder with enough space for all the pst's. I haven't tested this as I'm on Ex2010 and Export-Mailbox is a 2007 command.

Import-Csv “C:\Users.CSV” | ForEach-Object {
   $PSTPath = "E:\DriveForPST\" + $_.Alias + ".pst"
   Export-Mailbox -Identity $_.Alias -PSTFolderPath $PSTPath
 }

More help here:

Export-Mailbox: http://technet.microsoft.com/en-us/library/bb266964(v=exchg.80).aspx

Import-CSV: http://technet.microsoft.com/en-us/library/dd347665.aspx

Related Topic