Hi everyone,
I am new to PowerShell, and I am in a bit of a pickle attempting to create a conditional output for psping64 (Microsoft SysInternals tool).
The background issue:
I am troubleshooting high ping spikes on Wireless using Process Monitor, psping64.exe and my wits. The high ping spikes occur at various times, more while playing online games and less while browsing, on a wireless network. I know the source of the high ping spikes originates from my own machine and I want to isolate the process generating this issue.
What I want to do is use psping64 to run as many pings as possible and output all ping responses over 100 ms to a file, together with timestamps. I will then use the timestamps to filter Process Monitor events and isolate the troublesome process. A simple plan, in theory.
I got as far as creating a command in PowerShell which runs ping very quickly and outputs everything to a file, together with timestamps. The command is
.\psping64.exe -t -i 0 192.168.2.1 |Foreach{“{0} - {1}” -f (Get-Date),$_} | Tee-object -FilePath ping_log.txt
The output (excerpt) looks like this:
24-Jan-20 16:17:33 - Reply from 192.168.2.1: 2.04ms
24-Jan-20 16:17:33 - Reply from 192.168.2.1: 2.09ms
24-Jan-20 16:17:33 - Reply from 192.168.2.1: 2.07ms
24-Jan-20 16:17:33 - Reply from 192.168.2.1: 2.02ms
24-Jan-20 16:17:33 - Reply from 192.168.2.1: 2.07ms
24-Jan-20 16:17:33 - Reply from 192.168.2.1: 2.00ms
24-Jan-20 16:17:33 - Reply from 192.168.2.1: 2.08ms
24-Jan-20 16:17:33 - Reply from 192.168.2.1: 2.06ms
24-Jan-20 16:17:33 - Reply from 192.168.2.1: 2.02ms
24-Jan-20 16:17:33 - Reply from 192.168.2.1: 2.04ms
24-Jan-20 16:17:33 - Reply from 192.168.2.1: 2.13ms
24-Jan-20 16:17:33 - Reply from 192.168.2.1: 2.00ms
24-Jan-20 16:17:33 - Reply from 192.168.2.1: 2.01ms
24-Jan-20 16:17:33 - Reply from 192.168.2.1: 2.61ms
What I want to do is refine this command using a script in such a way that it only outputs data with “Reply from 192.168.2.1:” value greater than 100 ms, for example “24-Jan-20 16:38:26 - Reply from 192.168.2.1: 3000.17ms”. I imagine I would need to manipulate the output as a string and isolate the ping reply number, then if the condition met is true, putput the whole string to the txt file, but I am at a loss as to how to implement that.
Help would be much appreciated!
Thank you in advance!