Home  |  Services  |  About Us  |  Contact  | 


Brad's TechTips - Exchange Server & Outlook

[<< Full list of Exchange Server & Outlook tips.]
Exchange Server 2010: Export mailboxes to PST files from a workstation using PowerShell
Exchange Server 2010 supports PowerShell cmdlets from remote computers.  Here is a method that I use to schedule a PowerShell script to run daily and copy all mailboxes into PST files.
  1. Install 64-bit Outlook 2010 onto the server.
As of this writing (January, 2010), Outlook 2010 is still in beta release,
               so proceed at your own risk.
  2. Install the Exchange Server 2010 management tools onto your workstation.
Create the PowerShell Script:
  1.  Create a Powershell script using the editor of your choice.  Notepad will work fine.
  2.  Name the file BackupToPST.ps1 (or any meaningful name).
  3.  Enter the following line of code into the file to backup Brad's mailbox to the folder
       at S:\Mailboxes\:
          export-Mailbox -Identity MyDomain\brad -PSTFolderPath "S:\Mailboxes\Brad.pst"

       Note the generic syntax is:
          export-Mailbox -Identity <AccountName> -PSTFolderPath "<PathToPST>"
  4.  Repeat the previous step by adding additional lines to the script for any other mailboxes
       that you want to export.  Alternatively, use the syntax in the Microsoft article referenced
       at the end of this tip to export mailboxes based on criteria such as Active Directory
       Organizational Unit.
  4.  Save the file in a location such as c:\ExchangeScripts.

Create and schedule a batch file:
  1.  Create a batch file using the editor of your choice.  Notepad will work fine.
  2.  Name the file BackupToPST.bat (or any meaningful name).
  3.  Enter the following lines of code (all on a single line) into the file:
          PowerShell.exe -command ". 'C:\Program Files\Microsoft\Exchange
          Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto;

       Note that you may need to modify the path to RemoteExchange.ps1 and BackupToPST.ps1
       to meet your server's setup.
  4.  Save the file in a convenient location on your workstation and schedule it
       using the built-in Task Scheduler.
Additional Information
The export-Mailbox cmdlet actually has a large number of variables if you want to specify advanced export criteria.  Here is the full syntax, an explanation and examples of which can be found at the Microsoft Exchange Server TechCenter.
export-Mailbox -Identity <MailboxIdParameter> -PSTFolderPath <LongPath> [-AllContentKeywords <String[]>] [-AttachmentFilenames <String[]>] [-BadItemLimit <Int32>] [-Confirm [<SwitchParameter>]] [-ContentKeywords <String[]>] [-DeleteAssociatedMessages <SwitchParameter>] [-DeleteContent <SwitchParameter>] [-EndDate <DateTime>] [-ExcludeFolders <MapiFolderPath[]>] [-GlobalCatalog <Fqdn>] [-IncludeAssociatedMessages <SwitchParameter>] [-IncludeFolders <MapiFolderPath[]>] [-Locale <CultureInfo>] [-MaxThreads <Int32>] [-RecipientKeywords <String[]>] [-SenderKeywords <String[]>] [-StartDate <DateTime>] [-SubjectKeywords <String[]>] [-ValidateOnly <SwitchParameter>] [-WhatIf [<SwitchParameter>]]