简体   繁体   中英

How can I move multiple VMs in parallel using powercli?

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具有-RunAsync参数,该参数看起来应该可以执行所需的操作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM