ping multiple IP for Testing Network disconnecting Issue

Sometime you can have network disconnecting or disrupting for short period of time, a simple ping test will help a lot to diagnose the issue. PING with log example (without echo to screen):

Ping.exe -t | ForEach {"{0} - {1}" -f (Get-Date),$_} > C:\tmp\ping-log.txt

A PING with output to Screen:

Ping.exe -t | ForEach-Object {"{0} - {1}" -f (Get-Date),$_} | Tee-Object C:\tmp\ping-log.txt -Append

A greate tool I have found at nirsoft will cover all your ping needs including email on failure and multiple servers pinging :

Here is the script of sending email:

$Username = "YourMailUser";
$Password = "YourMailPassword";
$SendTo = "";
$MailServer = "";
$HostName = $args[0];
$IPAddress = $args[1];
$PingStatus = $args[2];
$FailedOn = $args[3];

$message = new-object Net.Mail.MailMessage;
$message.From = $Username;
$message.Subject = "Failed Ping On $HostName" ;
$message.Body = "Information about the failed ping: `r`nHost Name: $HostName`r`nIP Address: $IPAddress`r`nPing Status: $PingStatus`r`nPing Time: $FailedOn";

$smtp = new-object Net.Mail.SmtpClient($MailServer, "587");
$smtp.EnableSSL = $true;
$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);

Save this as Powershell script and use it as needed (set your own settings in it)’ in this example “send_message_failed_ping.ps1”

You can download the utility from here(local copy of the util , may be out of date) : direct link:

Good Luck

Leave a Reply

Your email address will not be published. Required fields are marked *