Follow

Exchange Migrator PowerShell Commands

The Exchange Migrator Powershell commands allow you to invoke the Exchange Migrator for importing and exporting PST files to and from Office 365.

Sample Scripts

The download below contains some sample scripts to help you get started with using the PowerShell commands.  There are 3 scripts in the .zip file:

  • A script to backup the calendars folder on all mailboxes to pst files
  • A script to backup the contents of mailboxes for the past 30 days
  • A script to backup the contents of all mailboxes

The Sample Scripts are attached to this document.

Installation

The Migrator module is installed along with the Exchange Migrator.

Loading the Module

Use the following command to load the module:

PS C:\> Import-Module MessageOps-Migrator

After the module is loaded you will have access to the cmdlets

Available CmdLets

  • Export-MessageOps.ToPST
  • Import-MessageOps.FromPST
  • Filtered Exports and Imports
  • Export-MessageOps.FilteredToPST
  • Import-MessageOps.FilteredFromPST

Export-MessageOps.ToPST

This cmdlet allows you to export a Mailbox to a PST, the module will use MAPI and Exchange Web Services to logon to the Mailbox and export the Items within it to a PST file. If the Mailbox is larger the 20 GB it will span the export over 1 or more files for reliability.

Parameters :

  • DestinationDirectory – Directory where PST file will be created
  • SourceMailbox – The PrimarySMTPAddress of the mailbox you want to export
  • Mailbox – (Switch) indicating to export the Mailbox
  • Archive  - (Switch) indicating to export the Archive
  • Credential – PSCredentials that will be used during the export this should be a Global Administrator with a mailbox in Office 365
  • ExportDumpster – Exports the dumpster folders only with the Mailbox in the RecoverableItems tree
  • UseDirectDiscover – Does a direct discover using MAPI, otherwise use DNS

Examples:

To Export the Primary Mailbox to PST

Export-Messageops.ToPST –DestinationDirectory c:\backup –SourceMailbox mailboxtoexport@messageops.com –mailbox

To Export the users Archive Mailbox to PST

Export-Messageops.ToPST –DestinationDirectory c:\backup –SourceMailbox mailboxtoexport@messageops.com –archive

Import-MessageOps.FromPST

This cmdlet allows the importing of a PST into an Office365 Mailbox or Archive.  All importing is performed using Exchange Web Services and MAPI.

Parameters:

  • FileName – Full filepath to where the PST is located
  • DestinationMailbox – The PrimarySMTPAddress of the mailbox you want to Import to
  • Mailbox – (Switch) indicating to import into the Mailbox
  • Archive – (Switch) indicating to import into the Archive
  • ImportIntoSubFolderOfMailbox – (Boolean) Indicating to import into the Subfolder named after the PST.  This is enabled by default.  If set to false the import will be done into the root folders.
  • Credential – PSCredentials that will be used during the export this should be a Global Administrator with a mailbox in Office 365
  • AddressReWrite – (Boolean) Use Address rewriting to rewrite native Exchange Addresses.  Enabled by default.
  • MAPIUpload – (Boolean) The is enabled by default and enables MAPI along with EWS to be used for uploads of messages. Setting this to false will mean only EWS will be used for uploads.
  • SkipDeletedItems – (Boolean) Skip importing the Deleted Items folder in the PST file.
  • UseDirectDiscover – (Boolean) Does a direct discover using MAPI, otherwise use DNS.

Examples:

To Import the pst file c:\temp\January2010.pst into a user archive mailbox:

Import-MessageOps.FromPST –filename c:\temp\January2010.pst –DestinationMailbox user2@messageops.com –Archive

To Import the file c:\temp\backup.pst into the root folder of a mailbox:

Import-MessageOps.FromPST –filename c:\temp\backup.pst –DestinationMailbox user2@messageops.com –Mailbox  –ImportIntoSubFolderOfMailbox $false

Performing Filtered Imports and Exports to and from PST Files

The MessageOps Exchange Migrator module contains two cmdlet’s that allow you to import and Export filtered Content to and from a PST file. The Content can be filtered by specific properties or using complex AQS or MAPI execSQL strings.

Import-MessageOps.FilteredFromPST

This cmdlet imports mail from a PST to Exchange Online Mailbox or Online Archive.

The Import-MessageOps.FilteredFromPST Cmdlet has the following 2 mandatory parameters:

  • FileName – (String) FullPath to the PST file name
  • DestinationMailbox – (String) PrimarySMTPAddress of the Exchange Online Mailbox

You then must specify a target location:

  • Mailbox – (Switch) Specify the Mailbox as the Import Destination
  • Archive – (Switch) Specify the Archive as the Import Destination

Filter Properties

One or more of these can be specified.  If multiple filters are specified the result will be an and of the filters.  For example subject = YYYYY and Body contains XXXYYYY.

  • Subject – Does a Substring or exact match on the Subject of a Message
  • Body – Does a Substring match of a part of body of a Message
  • Attachments – Does a Substring search of the Displayname, extension of filename
  • ReceivedDateFrom – Specify the DateTime to Import from
  • ReceivedDateTo – Specify the DateTime to Import To
  • SizeGreaterThan – Specify the Size in MB to Import Greater then
  • SizeLessThan – Specify the Size in MB to Import Less then
  • FilterString – Specify the raw filter String for the MapiTable where clause

Import Examples

Import messages with PDF attachments

PS C:\> Import-MessageOps.FilteredFromPST -FileName “c:\import\filename.pst” -DestinationMailbox mailbox@domain.onmicrosoft.com -Mailbox -Attachments “.pdf”

Import Messages from 2004 into the Mailbox Archive

PS C:\> Import-MessageOps.FilteredFromPST -FileName “c:\import\filename.pst” -DestinationMailbox mailbox@domain.onmicrosoft.com -Archive -ReceivedDateFrom [DateTime]::Parse(“2004/01/01″) -ReceivedDateTo [DateTime]::Parse(“2005/01/01″)

Import Messages less than 10 MB in the Mailbox Archive

PS C:\> Import-MessageOps.FilteredFromPST -FileName “c:\import\filename.pst” -DestinationMailbox mailbox@domain.onmicrosoft.com –Archive –SizeLessThan 10

Import Messages using a custom MAPITable String

PS C:\> Import-MessageOps.FilteredFromPST -FileName “c:\import\filename.pst” -DestinationMailbox mailbox@domain.onmicrosoft.com –Mailbox –FilterString “where (Categories = ‘one’) or (Categories = ‘two’)”

Export-MessageOps.FilteredToPST

This cmdlet exports mail to a PST from an Exchange Online Mailbox or Online Archive.

The Export-MessageOps.FilteredToPST Cmdlet has the following mandatory parameters:

  • SourceMailbox – (String) PrimarySMTPAddress of the Exchange Online Mailbox

You then must specify what to Export:

  • Mailbox – (Switch) Export the mailbox
  • Archive – (Switch) Export the archive

Filter Properties
One or more of these can be specifiedOne or more of these can be specified.  If multiple filters are specified the result will be an “and” of the filters.  For example subject = YYYYY and Body contains XXXYYYY.

  • Subject – Does a Substring or exact match on the Subject of a Message
  • Body – Does a Substring match of a part of body of a Message
  • Attachments – Does a Substring search of the Displayname, extension of filename
  • ReceivedDateFrom – Specify the DateTime to Export from
  • ReceivedDateTo – Specify the DateTime to Export To
  • SizeGreaterThan – Specify the Size in MB to Export Greater than
  • AQSString – Specify the raw EWS AQS String

Export Examples

Export messages with PDF attachments to PST
PS C:\> Export-MessageOps.FilteredToPST –SourceMailbox mailbox@domain.onmicrosoft.com –DestinationDirectory c:\exportDestination –Mailbox -Attachments “.pdf”

Export Messages from 2004 from the Mailbox Archive to PST

PS C:\> Export-MessageOps.FilteredToPST –SourceMailbox mailbox@domain.onmicrosoft.com –DestinationDirectory c:\exportDestination -Archive -ReceivedDateFrom [DateTime]::Parse(“2004/01/01″) -ReceivedDateTo [DateTime]::Parse(“2005/01/01″)

Export Messages larger than 10 MB from the Mailbox to PST

PS C:\> Export-MessageOps.FilteredToPST –SourceMailbox mailbox@domain.onmicrosoft.com –DestinationDirectory c:\exportDestination -Mailbox -SizeGreaterThan 10

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.