如何同时在多个Hyper-V群集上启动VM

时间:2017-10-17 09:30:34

标签: powershell

我们有4个Hyper-V群集,我创建了一个脚本,用于启动Hyper-V群集中的VM对象。

该脚本工作正常,唯一的问题是该脚本将启动第一个群集上的所有虚拟机,然后才启动第二个群集虚拟机。

我们是否可以在多个集群上同时启动虚拟机?

$clusters = Get-Content "c:\temp\Clusters.txt"
foreach ($clu in $clusters) {
    while ($true) {    
        write-host "Cluster VM resources bringing online  for cluster $clu" -ForegroundColor Green
        $c = Get-Cluster -name $clu | Get-ClusterResource | where { $_.Name -and $_.state -eq "offline"} 
        $count = $c.Length
        write-host "Current Count: $count" -ForegroundColor Green
        if ($count -eq 0) {
            break
        } else {
            echo $c[0..5] |Start-ClusterResource -ErrorAction SilentlyContinue -Verbose
            Start-Sleep 20
        }
    }
}

0 个答案:

没有答案
相关问题