There was a problem with the network in the office this morning. Rather than sit there staring at the screen, I decided to write a script that would let me know when things were back up. In my case, the indicator would be when the DHCP server gave me an IP, because that was the primary symptom—no IP.
Here’s the script. You will have to modify the Get-WMIObject query results to point to your NIC as that will vary per computer.
$nic = gwmi Win32_NetworkAdapterConfiguration | ? { $_.IPEnabled }
while ( $retval -ne 0 ) {
$retval = ($nic[0].RenewDHCPLease()).ReturnValue
}
Write-Host `a`a
In case you haven’t tried it, “`a” is the escape code for BELL which causes your internal PC speaker to go beep. This is really loud on many computers.
Also, “?” here is a built-in alias to the Where-Object cmdlet.

You should replace the write-Host with the following two lines.
$Voice = New-Object -com SAPI.SpVoice
$Voice.Speak( “Network problems”, 1 )
I love it! But the network would be up by the time the next command runs, so I’d have it say “Network problems have been resolved”