0

I've created a PowerShell script that creates a migration batch from Exchange on-premises to O365 Exchange Online using the New-MigrationBatch cmdlet. My next step is to halt the script until the the migration batch has been completed using a do-while loop.

Using just the following will return jobs of the specified status but need to narrow this down to specify job name too in order to be able to complete the script.

Get-Migrationbatch -Status Completed

I've tried the following but not getting anything returned:

Get-Migrationbatch | Where {$_.Status -eq "Completed" -and $_.Identity -eq "TEST-O365Migration#1"}

I've also tried the following and get nothing

Get-Migrationbatch -Identity TEST-O365Migration#1 | Where {$_.Status -eq "Completed"}

However, when using -ne rather than -eq in the condition it returns the job specified but looks like it's ignoring the condition after the pipe as changing this to "Stopped" returns the same job regardless of status.

Any ideas?

jshizzle
  • 351
  • 11
  • 29

1 Answers1

0

Bah my mistake, Using -like rather than -eq provides the result I'm after. What a waste of time explaining my above predicament.

jshizzle
  • 351
  • 11
  • 29
  • Aha, you may accept your own answer(https://stackoverflow.blog/2009/01/06/accept-your-own-answers/), so others can clearly see your issue is answered. :) – Sue.J Jul 17 '17 at 14:18
  • I nornally do as isn't the first time i've stumbled across the answer myself just after asking the question. Forgot this time but thanks for the reminder. – jshizzle Jul 17 '17 at 16:59