# Ping-WithTimestampAndLog

## Ping With Timestamp and Log

<p class="callout info">Remove line 1 from each code block to remove the logging to file.</p>

The script below pings the target 10 times.

```powershell
Start-Transcript -Force -Path "C:\temp\ping.log"
Test-Connection -Count 10 -ComputerName COMPUTERNAME | Format-Table @{Name='TimeStamp';Expression={Get-Date}},Address,ProtocolAddress,ResponseTime
```

The script below pings the target the maximum number of times for Powershell Versions below 7.2.

```powershell
Start-Transcript -Force -Path "C:\temp\ping.log"
Test-Connection -Count 2147483647 -ComputerName COMPUTERNAME | Format-Table @{Name='TimeStamp';Expression={Get-Date}},Address,ProtocolAddress,ResponseTime
```



The script below pings the target indefinitely.

<p class="callout warning">Requires Powershell Version 7.2 at minimum.</p>

```powershell
Start-Transcript -Force -Path "C:\temp\ping.log"
Test-Connection -Repeat -ComputerName COMPUTERNAME | Format-Table @{Name='TimeStamp';Expression={Get-Date}},Address,ProtocolAddress,ResponseTime
```