We had 4 Hyper-V clusters and I had created a script for powering on VM objects in Hyper-V clusters.
The script is working fine and the only thing is that the script will power on all VMs on first cluster and only then it is powering on second cluster VMs.
Is there any method we can start the VMs simultaneously on multiple clusters?
$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
}
}
}