Score:1

How can I see when a Ping was lost or not answered?

in flag

When I install Windows updates, or perform other maintenance that at some point involves one or more automatic reboots, I've had the same challenge over and over again for years:

  1. How can I check if the network connection to a specific device was interrupted and how can I log this with timecode? Even if the interruption lasted only a few seconds, as is common when rebooting a VM.

  2. How can I find out when and how long the network connection interruption (= reboot) occurred without a long search in logfiles?

  3. Is there any way to solve this challenge without special software? Only with Windows tools like PowerShell?

br flag
using ping or the equivalent has one problem ... it can respond before the OS has fully rebooted. you may want to test for when powershell comes back up OR for when `explorer.exe` is up and running. take a look at the parameters for `Restart-Computer` - especially the `-Wait` and `-For` ones. [*grin*]
RebootDeluxe avatar
in flag
Thanks Lee_Dailey for this hint.
br flag
you are most welcome! glad to help a tad ... [*grin*]
Score:1
az flag

I typically use this script to watch one or more computers going up and down.

# pinger.ps1

# example: pinger comp01
# pinger $list

param ($hostnames)

$pingcmd = 'test-connection'

$sleeptime = 1

$sawup = @{}
$sawdown = @{}

foreach ($hostname in $hostnames) { 
  $sawup[$hostname] = $false
  $sawdown[$hostname] = $false
}

while ($true) {
  foreach ($hostname in $hostnames) {
    if (& $pingcmd -count 1 $hostname -ea 0) {
      if (! $sawup[$hostname]) {
        echo "$([console]::beep(500,300))$hostname is up $(get-date)"
        $sawup[$hostname] = $true
        $sawdown[$hostname] = $false
      }
    } else {
      if (! $sawdown[$hostname]) {
        echo "$([console]::beep(500,300))$hostname is down $(get-date)"
date}
        $sawdown[$hostname] = $true
        $sawup[$hostname] = $false
      }
    }
  }
  sleep $sleeptime
}
pinger comp01,comp02

comp01 is up 12/02/2022 13:16:47
comp02 is up 12/02/2022 13:16:47
Score:0
in flag

Solution with PowerShell & Windows 10 / Windows Server >= 2016:

  1. Ping the host continuously and write the response with timecode to a text file (but also display it on the screen). You can use an IP address or hostname here:

    $computer = "192.168.1.29"; ping.exe -t $computer | Foreach{"{0} - {1}" -f (Get-Date),$_} | Tee "$env:userprofile\documents\Ping_$computer.txt" -append
    
  2. Open a 2nd PowerShell window and enter the following command. This will continuously monitor the text file from PowerShell window #1 and output all lines that do NOT contain the string "Reply". So all times where the ping did not work.

    Get-content "$env:userprofile\documents\Ping_192.168.1.29.txt" -Tail 0 -Wait | where { $_ -NotMatch "Reply" }
    
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.