Office 365 - EOL Migration Batches via PowerShell

Here are some PowerShell commands to get you going with migrating mailboxes to Office 365 over a hybrid deployment (this assumes you already have your hybrid deployment in place and working)



####  Set the ExecutionPolicy
Set-ExecutionPolicy Unrestricted -Scope Process -Force

####  Connect to Office 365
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

####  List existing Migration Endpoints
Get-MigrationEndpoint | select * | fl

####  List existing Migration Batches
Get-MigrationBatch

#list move requests
Get-MoveRequest | Select DisplayName,Status,Batchname

#list move requests and export to CSV
Get-MoveRequest | Select DisplayName,Status,Batchname | Export-CSV Currentlysync.csv


#### Check if IsDehydrated value is "True" or "False"
Get-OrganizationConfig | fl Identity, IsDehydrated

#### To Enable the advanced Exchange customizations please run the following command:
Enable-OrganizationCustomization

####  Set the Migration Endpoint
$MigrationEndpointOnPrem = Get-MigrationEndpoint -Identity "hybrid.domain.com"

####  Create the Migration Batch
New-MigrationBatch -Name Migration001 -SourceEndpoint $MigrationEndpointOnprem.Identity -TargetDeliveryDomain domain.mail.onmicrosoft.com -CSVData ([System.IO.File]::ReadAllBytes("D:\users.csv")) -BadItemLimit 100 -NotificationEmails neil@domain.co.uk

####  ExportMoveRequests and Batches to CSV
Get-MoveRequest | Select DisplayName,Status,Batchname | Export-CSV F:\MoveRequests.csv -NoTypeInformation

####  Manually force a mailbox within a batch to completed (just make the time and date pervious to current time and date)
Get-MoveRequest "Test.Account@domain.com" | Set-MoveRequest -SuspendWhenReadyToComplete:$false -preventCompletion:$false -CompleteAfter (Get-Date "02/10/2017 6:30 PM").ToUniversalTime()
Get-MoveRequest "Test.Account@domain.com" | Resume-MoveRequest

####  Check Timestamps
Get-MoveRequest "Test.Account@domain.com" | Get-MoveRequestStatistics | Select *TimeStamp,*name*

####  Check Status
Get-MoveRequest "Test.Account@domain.com"
Get-MoveRequest "Test.Account@domain.com" | Get-Moverequeststatistics

#Get MoveRequest and Statistics
Get-Date -Format g
Get-MoveRequest | Get-MoveRequestStatistics 

#Export all MoveRequest Stats to CSV

Get-MoveRequest | Get-MoveRequestStatistics  | Export-CSV F:\Get-MoveRequestStatistics.csv 

#find users in the batch
Get-MigrationUser -BatchId Migration002  | Export-Csv f:\migraiton002_Export.csv


#check for errors in the migration of the user or to identify why it has failed
Get-MoveRequestStatistics "neil.petersen@domain.com" -IncludeReport -DiagnosticInfo verbose | FL

#check for errors in the migration of the user or to identify why it has failed
Get-MoveRequestStatistics "neil.petersen@domain.com" -DiagnosticInfo verbose | FL

#check for errors in the migration of the user or to identify why it has failed, including te report
Get-MoveRequestStatistics "neil.petersen@domain.com" -DiagnosticInfo verbose -IncludeReport | FL

####  Export VERBOSE information about move requests Statistics to XML
Get-MoveRequestStatistics "neil.petersen@domain.com" -IncludeReport -DiagnosticInfo verbose | Export-CliXml .\GetMoveReport_YetToStart.xml 

#Get the statistics of the batch
Get-Date -Format g
Get-MigrationUser -BatchId Migration002 | Get-Moverequeststatistics

####  Export information about move requests Statistics
Get-Moverequeststatistics "neil.petersen@domain.com" -IncludeReport | Export-CSV F:\Get-Moverequeststatistics.CSV –NoTypeInformation -Encoding utf8

####  Complete Migration Batches
Complete-MigrationBatch -Identity " Migration001"

####  Export detailed information about specific migration batch | TXT file
Get-MigrationBatch -Identity Migration001 -IncludeReport | Format-List | Out-File F:\Get-MigrationBatch-IncludeReport-Diagnostic.txt -Encoding UTF8

####  Export detailed information about migration batches
Get-MigrationBatch -IncludeReport | Format-List | Out-File F:\Get-MigrationBatch-IncludeReport-Diagnostic9.txt -Encoding UTF8


###  Get an export of all mailbox detials within the batch and view errors
Get-MigrationUser -BatchId Migraiton029 | Get-MigrationUserStatistics -IncludeReport | Export-csv .\Get-MigrationBatch-IncludeReport-Diagnostic2.csv -Encoding UTF8

 ####  Export information about move requests Statistics
Get-Moverequeststatistics "Test.Account@domain.com" -IncludeReport | Export-CSV F:\Get-Moverequeststatistics.CSV –NoTypeInformation -Encoding utf8

####  Cleanup
Remove-PSSession $Session

Comments