Вопрос

Right now, I'm using the following scriptblock to move VMs in parrallel:

Start-Job -ScriptBlock {
    Add-PSSnapin VMware.VimAutomation.Core
    Add-PSSnapin VMware.VimAutomation.License
    Add-PSSnapin VMware.DeployAutomation
    Add-PSSnapin VMware.ImageBuilder
    Connect-VIServer MyVIServer
    Move-VM -VM $vm -Destination $TargetHost
}

This doesn't seem very efficient, and doesn't completely work (the jobs never complete). I shouldn't have to add the snap-ins and connect to the VIServer every time, but I don't know if there is a way around it. Is there any way to move multiple VMs at the same time and monitor when they have completed?

Also, the each VM won't necessarily go to the same ESX host, so I need to run the Move command separately for each one.

Это было полезно?

Решение

Move-VM has a -RunAsync parameter, which looks like it ought to do what you need.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top