Various ways to ping…
Powershell with a timestamp and output to file (can be an easy one-liner):
$ipaddress = "172.16.0.1" $dnsflag = "-a" $timestamp = Get-Date -f yyyyMMdd_HHmmss $outputfile = "$($env:USERPROFILE)\Desktop\Ping - $ipaddress - $timestamp.txt" $host.ui.RawUI.WindowTitle = "Pinging $ipaddress" ; ping -t $dnsflag $ipaddress 2>&1 |Foreach{'{0} - {1}' -f (Get-Date -f yyyyMMdd_HHmmss),$_} | select -skip 1 | Tee-Object "$outputfile"
Command Prompt one-liner to log to file with timestamp:
title Pinging 172.16.0.1 &ping -a -t 172.16.0.1|cmd /q /v /c "(pause&pause)>nul & for /l %a in () do (set /p "data=" && echo( !date! !time! !data! ) && echo !date! !time! !data! >> "C:\Users\Mathew\Desktop\Logging-Output\Ping -2019-12-08_230103_172.16.0.1.txt"&ping -n 2 localhost>nul"