Hi,
Is there a way to do so?
I mean to chain in some way DATE command with PING command.
The Tech,
Welcome to the forums.
Would you like to elaborate a little more detailed what you mean with “to chain”? If you already have some code please share it.
The ping command itself doesn’t output the time of each command executed.
I wonder if there is a way to make it to output also the time, maybe with collaboration of the date command.
What do you mean with “the time of each command”? Did you built a loop or something for you Test-Connection
?
I would like to get this output:
Reply from 8.8.8.8: bytes=32 time=90ms TTL=111 Saturday, April 24, 2021 11:25:13 PM
Something like that?
Here you find more examples: 7 Ways to Timestamp Ping Results • Raymond.CC
Ping.exe -t 8.8.8.8 | ForEach {“{0} – {1}” -f (Get-Date).DateTime,$_}
Since this is the PowerShell forum I’d recommend using the native PowerShell cmdlet instead of the old Ping.
You can combine the output of any cmdlet with a timestamp by using a calculated property like this:
Test-Connection -ComputerName 8.8.8.8 |
Select-Object -Property PSComputerName, Address, IPV4Address, IPV6Address, BufferSize, ResponseTime, @{Name = 'TimeStamp'; Expression = {Get-Date}} |
Format-Table -AutoSize