skip to Main Content

Using PowerShell for view and export information about mailbox migration to Office 365 | Part 3#5

In the current article and the next article, we review the various PowerShell cmdlets that we can use for viewing and export information about the process of Exchange mailbox migration process.

The “mailbox migration” PowerShell commands that we review in this article are:

  • Get-MigrationBatch
  • Get-MoveRequest
  • Get-MoveRequestStatistics

1. Migration batches | Get-MigrationBatch

The term – “Migration Batch”, define an entity that serves as a “logical container”, that contain the mailboxes (and their associated users), that we migrate from the source Exchange server to the destination Exchange server (Exchange Online in our scenario).

Get information about specific migration batch

PowerShell command syntax

Get-MigrationBatch -Identity <Migration BATCH name>

PowerShell console output example

 
PS C:\> Get-MigrationBatch "Eyal Migration batch -001" |fl 


RunspaceId                 : 2771b392-d73b-4639-b63d-f4646c49c0af
Identity                   : Eyal Migration batch -001
Status                     : Completed
State                      : Completed
Flags                      : None
WorkflowStage              : Processing
TriggeredAction            : None
BatchGuid                  : fb2529fe-b9bf-446a-accd-3819e6bef03c
TotalCount                 : 2
ActiveCount                : 0
StoppedCount               : 0
SyncedCount                : 0
FinalizedCount             : 2
FailedCount                : 0
FailedInitialSyncCount     : 0
FailedIncrementalSyncCount : 0
CompletedWithWarningCount  : 0
PendingCount               : 0
ProvisionedCount           : 0
ValidationWarningCount     : 0
ValidationWarnings         : {}
Message                    : 
CreationDateTime           : 2/23/2017 10:41:09 AM
CreationDateTimeUTC        : 2/23/2017 8:41:09 AM
StartDateTime              : 2/23/2017 10:41:09 AM
StartDateTimeUTC           : 2/23/2017 8:41:09 AM
InitialSyncDateTime        : 
InitialSyncDateTimeUTC     : 
InitialSyncDuration        : 
LastSyncedDateTime         : 2/23/2017 10:47:28 AM
LastSyncedDateTimeUTC      : 2/23/2017 8:47:28 AM
FinalizedDateTime          : 
FinalizedDateTimeUTC       : 
SubmittedByUser            : Eyal@o365info.com
OwnerId                    : EURPR05A001.prod.outlook.com/Microsoft Exchange Hosted Organizations/o365info2.onmicrosoft.com/Eyal
OwnerExchangeObjectId      : 7646f17d-bf1f-4e07-8698-4e71ab4dad80
NotificationEmails         : {Eyal@o365info.com}
ExcludedFolders            : {}
MigrationType              : ExchangeRemoteMove
BatchDirection             : Onboarding
Locale                     : en-US
Reports                    : {When migration report was created:2/23/2017 9:19:17 AM; Migration report URL:https://outlook.office365.com/ecp/Migration/DownloadReport.aspx?HandlerClass=
                             MigrationReportHandler&Name=MigrationReport.csv&DelegatedOrg=o365info2.onmicrosoft.com&realm=o365info2.onmicrosoft.com&exsvurl=1&Identity=RgAAAAAKqOiME1CMQ
                             LkjirbMEluxBwCuLv0wEUQXTp3grhMeQsz8AAAh0Mi_AACuLv0wEUQXTp3grhMeQsz8AAN-JngxAAAJ; Error report URL:}
IsProvisioning             : False
BatchFlags                 : ReportInitial
WorkflowControlFlags       : None
AutoRetryCount             : 0
CurrentRetryCount          : 0
AllowUnknownColumnsInCsv   : False
DiagnosticInfo             : 
SupportedActions           : Remove
SourceEndpoint             : mail.o365info.com
TargetEndpoint             : 
SourcePublicFolderDatabase : 
TargetDatabases            : {}
TargetArchiveDatabases     : {}
TargetDAGs                 : {}
BadItemLimit               : 10
LargeItemLimit             : 0
MoveOptions                : {}
SkipMoving                 : {}
SkipMerging                : {}
InternalFlags              : {}
PrimaryOnly                : False
ArchiveOnly                : False
TargetDeliveryDomain       : o365info2.mail.onmicrosoft.com
SkipSteps                  : None
Workflow                   : Steps: [(Injection), (Processing)]
WorkflowTemplate           : 
Report                     : 
StartAfter                 : 
StartAfterUTC              : 
CompleteAfter              : 
CompleteAfterUTC           : 
IsValid                    : True
ObjectState                : Unchanged

Export detailed information about specific migration batch | TXT file

Get-MigrationBatch -Identity migration-003 -IncludeReport -Diagnostic | Format-List | Out-File c:\temp\"Get-MigrationBatch-IncludeReport-Diagnostic.txt" -Encoding UTF8

Export detailed information about ALL migration batches

Export information to TXT file

Get-MigrationBatch -IncludeReport -Diagnostic | Format-List | Out-File c:\temp\"ALL Migration -Get-MigrationBatch-IncludeReport-Diagnostic.txt" -Encoding UTF8

Export information to XML file

Get-MigrationBatch -IncludeReport -Diagnostic | Export-Clixml
c:\temp\"ALL Migration Get-MigrationBatch-IncludeReport-Diagnostic.xml" -Encoding UTF8

Migration batch status

Using the “Status” parameter, we can get information about the existing migration batch that has a specific “Status”.

The migration batch type of “Statuses” value could be as follow:

  • Completed
  • CompletedWithErrors
  • Completing
  • Corrupted
  • Created
  • Failed
  • IncrementalSyncing
  • Removing
  • Starting
  • Stopped
  • Syncing
  • Stopping
  • Synced
  • SyncedwithErrors
  • Waiting

To view a migration batch with a specific status, we can use the following PowerShell syntax

Display all migration batch with status such as “Completed”

PowerShell command example

Get-MigrationBatch -Status Completed

PowerShell console output example

PS C:\> Get-MigrationBatch -Status Completed 

Identity                  Status    Type               TotalCount
--------                  ------    ----               ----------
Eyal Migration batch -001 Completed ExchangeRemoteMove 2         
Eyal Migration batch -002 Completed ExchangeRemoteMove 2      

Export information about all migration batch with the status “Not Completed” | TXT file

PowerShell command example

Get-MigrationBatch | Where {$_.status -ne ”Completed”} | Get-MoveRequestStatistics | Format-List | Out-File c:\temp\"Get-MigrationBatch Not Completed.txt" -Encoding UTF8

3. Move requests

The term – “Move request”, define the Exchange mailbox that we migrate from the “source Exchange server” to the “destination Exchange server”.

The two PowerShell cmdlets that we use for getting information about the move requests of the “mailbox entity” are:

  • Get-MoveRequest
  • Get-MoveRequestStatistics

2. Using the Get-MoveRequest command

The PowerShell command Get-MoveRequest, get basic information about a property of a specific mailbox that we migrate.

Get information about specific Move Request

PowerShell command syntax

Get-MoveRequest < Move Request name>

PowerShell console output example

PS C:\> Get-MoveRequest onpremmbx-01@o365info.com | Format-List


RunspaceId                 : 2771b392-d73b-4639-b63d-f4646c49c0af
ExchangeGuid               : e3254cfe-81c0-496e-84db-80e9190342e5
SourceDatabase             : 
TargetDatabase             : EURPR05DG136-db018
SourceArchiveDatabase      : 
TargetArchiveDatabase      : 
Flags                      : CrossOrg, Pull
RemoteHostName             : mail.o365info.com
BatchName                  : MigrationService:Eyal Migration batch -001
Status                     : Completed
RequestStyle               : CrossOrg
Direction                  : Pull
IsOffline                  : False
Protect                    : False
Suspend                    : False
SuspendWhenReadyToComplete : False
AdministrativeUnits        : {}
Alias                      : onpremmbx-01
ExtensionCustomAttribute1  : {}
ExtensionCustomAttribute2  : {}
ExtensionCustomAttribute3  : {}
ExtensionCustomAttribute4  : {}
ExtensionCustomAttribute5  : {}
DisplayName                : onpremmbx-01
ExternalDirectoryObjectId  : c4d8af0e-69f2-4534-b79c-04ddaea7d074
LastExchangeChangedTime    : 
RecipientType              : UserMailbox
RecipientTypeDetails       : UserMailbox
Identity                   : onpremmbx-01
IsValid                    : True
ExchangeVersion            : 0.20 (15.0.0.0)
Name                       : onpremmbx-01
DistinguishedName          : CN=onpremmbx-01,OU=o365info2.onmicrosoft.com,OU=Microsoft Exchange Hosted Organizations,DC=EURPR05A001,DC=prod,DC=outlook,DC=com
Guid                       : 1e697c91-3a05-490d-a1d2-4434471cd1d9
OrganizationId             : EURPR05A001.prod.outlook.com/Microsoft Exchange Hosted Organizations/o365info2.onmicrosoft.com - EURPR05A001.prod.outlook.com/ConfigurationUnits/o365info2.onmicrosoft.com/Configuration
Id                         : onpremmbx-01
OriginatingServer          : DB3PR05A001DC03.EURPR05A001.prod.outlook.com
ObjectState                : Changed

Export information about specific Move Request | TXT file

Get-MoveRequest onpremmbx-01@o365info.com | Format-List | Out-File c:\temp\"Get-MoveRequest.txt" -Encoding UTF8

Get information about ALL existing Move mailbox requests

When we use the PowerShell, command Get-MoveRequest without relating to a specific move request, meaning, without specifying the identity of a specific move request, the PowerShell command will display information about ALL existing “Move Requests”.

General note – in case you are performing mailbox migration that includes tens or hundreds of mailboxes, the process of exporting information about each of these migrated mailboxes, could take a long time.

Export information about ALL Move Requests | TXT file

PowerShell command example

Get-MoveRequest | Format-List | Out-File c:\temp\"Get-MoveRequest.txt" -Encoding UTF8

Export information about MoveRequest with a specific status

Each of the “move requests” could have a specific “status” such as – Completed ,Failed and so on.

The available status codes values are as follow:

  • AutoSuspended
  • Completed
  • CompletedWithWarning
  • CompletionInProgress
  • Failed
  • InProgress
  • None
  • Queued

In case you want to get information only about the specific status of “Move requests”, you can use the following PowerShell syntax:

Export information about ALL Move Requests which their status is not “completed” | TXT file

Get-MoveRequest | Where {$_.status -ne ”Completed”} | Get-MoveRequestStatistics | Format-List | Out-File c:\temp\"Get-MoveRequest- status is not completed.txt" -Encoding UTF8

Export information about ALL Move Requests which their status is – “Failed” | TXT file

PowerShell command example

Get-MoveRequest | Where {$_.status -eq ”Failed”} | Get-MoveRequestStatistics | Format-List | Out-File c:\temp\"Get-MoveRequest- status is Failed.txt" -Encoding UTF8

3. Using the MoveRequestStatistics command

The purpose of the PowerShell command Get-MoveRequestStatistics, is to get detailed information about the “migrated mailbox content”.

For example,

ItemsTransferred – information about the number of mail items, that was already transferred.

PercentComplete – as the name implies, information about the “Complete percentage” of the mailbox migration process.

Get move requests Statistics information for specific Move Request

PowerShell command syntax

Get-MoveRequestStatistics <Migrated mailbox>

PowerShell console output example

PS C:\> Get-MoveRequestStatistics onpremmbx-01@o365info.com

DisplayName  StatusDetail TotalMailboxSize           TotalArchiveSize PercentComplete
-----------  ------------ ----------------           ---------------- ---------------
onpremmbx-01 Completed    7.148 MB (7,495,583 bytes)                  100   

Export information about specific move requests Statistics | TXT file

Get-MoveRequestStatistics onpremmbx-01@o365info.com | Format-List | Out-File c:\temp\"Get-MoveRequestStatistics.txt" -Encoding UTF8

If we want to eliminate unmercenary data and get a “clear view” of the mailbox migration Statistics, we can ask from PowerShell to display only specific data fields.

PowerShell command example

Get-MoveRequestStatistics onpremmbx-01@o365info.com | Select MailboxIdentity,Status,WorkloadType,RecipientTypeDetails,SourceServer ,BatchName,TotalMailboxSize,TotalMailboxItemCount,TotalArchiveSize,BytesTransferred,BytesTransferredPerMinute,ItemsTransferred,PercentComplete  | Format-List | Out-File c:\temp\"Get-MoveRequestStatistics.txt" -Encoding UTF8

Combine the Get-MoveRequest + Get-Moverequeststatistics commands

A nice option that we can use when using PowerShell is a “combination” of two or more PowerShell command. The formal term for this method is “pipeline”.

In the following scenario, we a combination of two PowerShell commands:

  • Get-MoveRequest
  • Get-MoveRequestStatistics

The first command Get-MoveRequest will “fetch” all the existing “Move Requests”.

The second command Get-MoveRequestStatistics, will use the “move requests list” form the first command, and add the “statistics information” for each mailbox move requests.

Combine the Get-MoveRequest + Get-Moverequeststatistics commands

PowerShell command syntax

Get-MoveRequest| Get-Moverequeststatistics

PowerShell console output example

PS C:\> Get-MoveRequest| Get-Moverequeststatistics 

DisplayName  StatusDetail TotalMailboxSize           TotalArchiveSize PercentComplete
-----------  ------------ ----------------           ---------------- ---------------
onpremmbx-02 Completed    7.148 MB (7,495,429 bytes)                  100            
onpremmbx-03 Completed    7.148 MB (7,495,563 bytes)                  100            
onpremmbx-04 Completed    7.148 MB (7,495,449 bytes)                  100            
onpremmbx-01 Completed    7.148 MB (7,495,583 bytes)                  100      

Get + Export information about ALL concurrent move requests Statistics + troubleshooting information

In this scenario, we add the additional parameters- “IncludeReport” and “Diagnostic” for getting more details about the Move Request Statistics.
Most of the time, we will use this additional parameter is a troubleshooting scenario.

In addition, I add an example of- exporting information to XML file because in case that we need to deliver the exported information to Microsoft support for further analysis, this is the “preferred” file format.

Combine the Get-MoveRequest + Get-Moverequeststatistics commands

Export information to TXT file

Get-MoveRequest| Get-Moverequeststatistics -IncludeReport -Diagnostic | Format-List | Out-File c:\temp\"Get-Move-Request-Get-Moverequeststatistics.txt" -Encoding UTF8

Export information to CSV file

Get-MoveRequest| Get-Moverequeststatistics -IncludeReport -Diagnostic | Export-CSV c:\temp\"Get-Move-Request-Get-Moverequeststatistics.CSV" –NoTypeInformation -Encoding utf8

Export information to XML file

Get-MoveRequest| Get-Moverequeststatistics -IncludeReport -Diagnostic | Export-Clixml
c:\temp\"Get-MoveRequestStatistics-IncludeReport-Diagnostic.xml" -Encoding UTF8

Other variation of the PowerShell command syntax that we can use for getting information about move requests with a specific status such as Failed move requests + statistics information about each move requests could be:

PowerShell command example

Get-MoveRequest -movestatus Failed| Get-moverequeststatistics |select DisplayName,SyncStage,Failure*,Message,PercentComplete,largeitemsencountered,baditemsencountered| ft -autosize

Download Mail Migration PowerShell script.

The o365info Team

The o365info Team

This article was written by our team of experienced IT architects, consultants, and engineers.

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *