I was trying to execute x different server restarts with a PowerShell script, but as soon as it hits my for loop it just ends and I don't know where I made the mistake.
Code:
$x = Read-Host "How much you want to restart"
for ($i=0; $i -eq $x; $i++)
{
$name = read-host "Enter Servername" $i "to restart"
Restart-Computer -ComputerName $name -wait
write-host "Server" $name "restarded"
}
Edit: thx to the answer I corrected the $i++ but still it does end immediately after the number is entered.
i++-->$i++?