I have an array with strings:
$Names = @("Name1","Name2","Name3","Name4","Name5","Name6","Name7","Name8","Name9","Name10")
I want to do the following:
I want to have a Skip variable, where I will cut my array in chunks, and want to print my names with 5 seconds in between.
I have tried it by doing the following:
$BatchSkip = 5
for($i = 0; $i -lt $names.Count; $i += $BatchSkip){
$tempArray = $names |Select-Object -First $BatchSkip
foreach ($name in $tempArray)
{
write-host $name
} Start-Sleep -Seconds 5
}
But this keeps printing the same names. What factor is missing in my code to implement that it ‘loops’ over my array?