Rebooting a switch is easy. Having patience enough to not frantically click the F5 button to check if the webinterface is back online is next to impossible. Here’s a quick PowerShell snippet with a solution!

isOnline?

The isOnline function uses Test-Connection every 2 seconds. The -quiet parameter is handy. It returns a $true if one of both pings are succesfull. Otherwise, it will return a $false.

Then, we log a timestamp for each time the target is switching states. A neat log for future reference!

Finally, we also display our current state in some beautiful colours. PowerShell contains a nifty little trick to update the previous line of our terminal.

Write-Host " `r "



Here you go! Have fun rebooting your networked devices.

Tip: You could also use this instead of ping -t. Sometimes I don’t like the endless stream of output in the command prompt.