Quick migrate multiple VM’s using PowerShell

As users of System Center Virtual Machine Manager would know, trying to quickly live migrate multiple VM’s can be a slow and tedious task.

Whilst I always recommend to user of VMM to use the Migrate Virtual Machine function or the Start Maintenance Mode options, sometimes I need to react quickly and the normal VMM way isn’t fast enough. This is where PowerShell comes in…

$VMS = Get-SCVirtualMachine | ogv -passthru
$VMHost = Get-SCVMHost | ogv -passthru
ForEach ($VM in $VMS)
 Move-SCVirtualMachine -VM $VM -VMHost $VMHost -HighlyAvailable $true -RunAsynchronously -UseDiffDiskOptimization

Hope this helps!