Cadzow Knowledgebase


Welcome
Contact Us
Professional
Services

Consulting
Knowledgebase/
Site Search

Remote Support

Print Friendly

Scripting: Exchange 2010 — Exporting Mailboxes to Personal Folders Files

Microsoft Exchange 2010 Service Pack 1 has the ability to export a mailbox to a Personal Folders file (.PST) natively (unlike Exchange 2007 which requires a 32-bit version of Microsoft Outlook on the same system) using the New-MailboxExportRequest cmdlet.

Setting Up

  1. Open the Exchange Management Shell in elevated mode and enter:

    New-ManagementRoleAssignment -Role "Mailbox Import Export" -User Administrator

    where Administrator is the name of the user doing the export requests.

  2. Exit Exchange Management Shell.

  3. Create a folder and share it. Give the folder and the share Full Access to the group Exchange Trusted Subsystem.

    Let's say the UNC path for the share is \\Server\Mailboxes.

Running The Task

  1. Save the following commands into a text file, with the extension ps1:

      Get-MailboxExportRequest | where {$_.status -eq "Completed"} | Remove-MailboxExportRequest -Confirm:$false

      Get-MailboxExportRequest | where {$_.status -eq "Failed"} | Remove-MailboxExportRequest -Confirm:$false

      $Export = Get-Mailbox

      $Export|%{$_|New-MailboxExportRequest -FilePath "\\Server\Mailboxes\$($_.alias).pst"}

  2. Save the following into a text file, with the extension cmd or bat:

      PowerShell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\V14\Bin\exshell.psc1" -Command ". '<path>\ExportMailboxes.ps1'"

  3. Run the cmd/bat script from an elevated command prompt or create a task. In both cases, you must be logged in as the user granted permission to run the exports or schedule the task for that user context.

How It Works

When an export request is completed, it remains in the system for 30 days (by default). So the first lines of the script remove any existing requests which have completed or failed.

The remaining lines create an export request for each mailbox, and specifies the destination as a Personal Folders file called <Mailbox Alias>.pst.

The command in the batch file executes the script with PowerShell with the Exchange cmdlets loaded.

Because this process queues a “request” for a mailbox export, at the time the script finishes, the exports have not yet finished (or started, usually).

Copyright © 1996-2019 Cadzow TECH Pty. Ltd. All rights reserved.
Information and prices contained in this website may change without notice. Terms of use.


Question/comment about this page? Please email webguru@cadzow.com.au