Recently, I have created a script that returns a beep sound when the connection is re-established. I would like to share this script here on my website.
Assume your network connectivity is broken. You wait until the connection is restored. In addition, you want to hear a sound when the connection is re-established. For this task, just use my script.
Note that the ping is performed 10000 times. This is realized by $_ and 1…10000.
This script was tested in PowerShell 7.
1..10000 | ForEach-Object {
If ((Test-Connection -ComputerName 8.8.8.8 -Count $_).Status.Value__ -eq '0') {
[System.Console]::Beep(200,1000)
}
}
Have fun!
Categories: PowerShell