Created
August 15, 2019 12:53
-
-
Save TScalzott/f807a1ddf954582dae4fc031bed2c7eb to your computer and use it in GitHub Desktop.
Log timestamped ping replies and timeouts to the screen and a logfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.DESCRIPTION | |
Log timestamped ping replies and timeouts to the screen and a logfile | |
.PARAMETER host | |
The host or IP to ping | |
.EXAMPLE | |
PingLog.ps1 www.google.com | |
#> | |
param ( | |
[Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string[]]$hostname | |
) | |
Write-Output "Logging $hostname pings to $env:USERPROFILE\Documents\`n" | |
PING.EXE $hostname -t | | |
Select-String "(Reply|Timed)" | | |
ForEach-Object $_ { | |
"$((Get-Date).ToString('u')): $_" | |
} | | |
Tee-Object -FilePath "$env:USERPROFILE\Documents\PingLog-$((Get-Date).ToString("yyyyMMdd")).txt" -Append |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment