Log failed ping with PowerShell

Hello,

You may will need to log every lost ping during a long periode of time, you can use PowerShell :

while (1){
   if(!(Test-Connection -ComputerName google.com -Count 1 -Quiet)){Add-Content -LiteralPath c:powershellPingLog.log -Value (Get-Date -Format "dd/MM/yyyy - HH:mm:ss")} 
}

You can end the loop with a “Ctrl+C” and look at the log to see each failled ping.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.