PowerShell Ping Test
Used this little script the other day for a basic network test to an access point I was testing. It just pings the device every 10 seconds (or whatever you set it at) and only outputs when there is an error and the time it occurred. Made for an easy way to leave this running over the weekend and see any time that the device went offline.
PingTest.PS1
function Test-Ping { param($ip) trap {$false; continue} $timeout = 1000 $object = New-Object system.Net.NetworkInformation.Ping (($object.Send($ip, $timeout)).Status -eq 'Success') } $killswitch=1 Write-Host "Running ping test to 192.168.10.9 every 10 seconds. Logs errros to screen. Press <CTRL> C to stop." -Fo Cyan while ($killswitch -ne 0) { If (!(Test-Ping 192.168.111.5)) { Write-Host 'Lost connectivity at: ' $(Get-Date -format "dd-MM-yyyy @ hh:mm:ss") -Fo Red } Else { Start-Sleep 10 } }