0

I have created a script to start the VM resources on clusters. The script is working fine but it is starting all VM resources cluster by cluster only.

My requirement is starting the 5 VM resources for the first cluster then starting another 5 VM resources in the second cluster, again it has to start 5 VM resources on the first cluster and another 5 VM resources on the second cluster

can anyone help me, please?

Cluster resources power on start here

$clusters = Get-Content "c:\temp\Clusters.txt"
foreach ($clu in $clusters){
    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"} | Start-ClusterResource -ErrorAction SilentlyContinue -Verbose
    echo $c
}
Nkosi
  • 235,767
  • 35
  • 427
  • 472
  • 1
    Try inserting `Select-Object -First 5` as a pipeline segment before `Start-ClusterResource`. – mklement0 Dec 24 '17 at 04:59
  • Check the following https://stackoverflow.com/questions/20101579/can-powershell-loop-through-a-collection-n-objects-at-a-time – Nkosi Dec 24 '17 at 05:22
  • the script is stopped after starting 5 objects in the first cluster + $c = Get-Cluster -name $clu | Get-ClusterResource | where { $_.Name -and $_. ... + ~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-ClusterResource], ClusterCmdletException + FullyQualifiedErrorId : Get-ClusterResource,Microsoft.FailoverClusters.PowerShell.GetResourceCommand – Chandra Sekhar Dec 24 '17 at 06:02

0 Answers0