Exchange 2007 Powershell Mailbox Export to PST in Mass

So today I was asked to delete a bunch of email accounts off of Exchange that were tied to users that are no longer with the company. Due to the security requirements we follow where I work, we have to maintain a list of users that previously worked for the company. We maintain them in a Disabled User OU in AD to easily ID said users. However we are not required to maintain email for nearly as long, so we were asked to make a backup of the mailbox’s to PST files, just in case, and put them on a drive and into a vault prior to removal of the emails. In this 1st run after the policy was created we found we had a bunch of mailboxes to export so we came up with a simple one liner to do this for us.

To that end we used Powershell to export the users in the “Disabled OU” in AD and find any mailboxes associated with those users and export them.

The requirements to make this work under Exchange 2007 are a bit of a pain if you are running Windows 7 64bit those requirements are listed below.

A Windows 7 32bit machine
Exchange tools (sp1) installed on the local machine
Outlook 32bit installed

Once you have that you can actually run the Exchange Powershell script I used:

[PS] C:\>Get-Mailbox -OrganizationalUnit "domain/Disabled User OU" | 
add-mailboxpermission -accessrights fullaccess -user ADAdminAccount -confirm:$false | 
Export-Mailbox -PSTFolderPath "C:\Path\"

So this script, goes in and retrieves a list of mailboxes in a given OU, grants the user running the script “ADAdminAccount” permission to export the mail, and then exports it to a local drive with one pst file per user in the OU in question. Very handy.


, ,

  1. #1 by Sleek Suzy on May 3, 2012 - 5:16 pm

    I have searched high and low and can not find a delete bulk mailbox with powershell example. I have been trying to put it together from several other examples but no luck do far. Here is a sample of what I have tried:

    [PS] C:\>$mb = Get-Mailbox -Database qt-mbx-cls.oberonmedia.local\china | select
    Alias | Remove-Mailbox -Identity Alias -Permanent $true -Confirm:$false -whatif

    I have also tried various foreach loops, but just get errors

    Any help is greatly appreciated!

  2. #2 by Robert on May 3, 2012 - 10:29 pm

    I created a post to cover this Lets follow up on that post if you have more questions.

  3. #3 by Sleek Suzy on May 4, 2012 - 10:22 am


    • #4 by Robert on May 4, 2012 - 10:52 am

      Let me know if it works or if you have problems. Good Luck!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: