1..255 | %{
$IP = "192.168.2.$_"
If (Test-Connection -count 1 -comp $IP -quiet) {
$user = 'admin'
$pass = 'admin'
$pair = "$($user):$($pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
$Headers = @{
Authorization = $basicAuthValue
}
$URL = "http://"+$IP+"/servlet?key=Reboot"
Invoke-WebRequest -Uri $URL -Headers $Headers
}
}