PowerShell

Looping PowerShell Commands

While doing Exchange or Office 365 migration the best way to monitor migration progress is using powershell commands, but in order to do that you might have to keep entering the same commands repeatedly.

To get hands free below script can be used with appropriate time to repeat the command itself in loop.. e.g.

PS C:\WINDOWS\system32> while ($true)
>> {
>> Get-MigrationUser | where {($_.BatchID -eq "migration-users-batch1") -and ($_.Status -eq "Synced")} | measure-object
>> sleep -seconds (60*5)
>> }

..just change the third line with your powershell command and time (60 sec * 5 Minutes) required to repeat the command.. to end press CNTR + C.

 

Advertisements