Hello,
How do you loop through an array 10 at a time until complete? I would like to reboot quite a few servers in a cluster and have come up with the following but I am curious is there is a way get 10, then get the next 10 and the next 10, etc until finished. The cluster can grow later so I am trying to build something a bit more dynamic.
foreach ($server in $pascal[0..9]){write-host $server is rebooting }
Start-Sleep -Seconds 30
foreach ($server in $pascal[10..19]){write-host $server is rebooting }
Start-Sleep -Seconds 30
foreach ($server in $pascal[20..29]){write-host $server is rebooting }
Start-Sleep -Seconds 30
foreach ($server in $pascal[30..39]){write-host $server is rebooting }
Start-Sleep -Seconds 30
foreach ($server in $pascal[40..49]){write-host $server is rebooting }
Start-Sleep -Seconds 30
foreach ($server in $pascal[50..59]){write-host $server is rebooting }
Start-Sleep -Seconds 30
foreach ($server in $pascal[60..69]){write-host $server is rebooting }
Start-Sleep -Seconds 30
etc..