#Used to continuously ping a host and get an audible alert when it is back up.
function ContinuousPing-Beep
{
param([string]$computer)
$ping = new-object System.Net.NetworkInformation.Ping
$result = $ping.Send($computer);
if($result.Status -eq "Success")
{
Write-Host "Reply received from $computer" -Foreground green
Write-Host `a;
}
else
{
do{$result = $ping.Send($computer);Write-Host "Reply from $computer. Destionation host unreachable." -Foreground red}
until($result.Status -eq "Success")
Write-Host "Reply received from $computer" -Foreground green
Write-Host `a;
}
}
function ContinuousPing-Voice
{
param([string]$computer)
$voice = new-object -com SAPI.SpVoice
$ping = new-object System.Net.NetworkInformation.Ping
$result = $ping.Send($computer);
if($result.Status -eq "Success")
{
$voice.Speak("Reply received from $computer", 1)
}
else
{
do{$result = $ping.Send($computer);Write-Host "Reply from $computer. Destionation host unreachable." -Foreground red}
until($result.Status -eq "Success")
$voice.Speak("Reply received from $computer", 1)
}
}
ContinuousPing-Beep "192.168.1.1"
ContinuousPing-Voice "192.168.1.1"
2 comments:
Very nice Rob.
Cheers,
Pash
How can I make this continual?
Post a Comment