-
-
Save IISResetMe/67eb5d4d4e48eb5d7cea to your computer and use it in GitHub Desktop.
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
# | |
# Ping-Forever.ps1 | |
# | |
# Modified version of alexinnes/ConstantPingToServer.ps1 (https://gist.github.com/alexinnes/b2076c88700020af3963) | |
# | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$true)] | |
[string]$ComputerName, | |
[string]$LogDirectory = 'C:\ping logs\' | |
) | |
# File name based on date | |
$FileName = '{0:dd-MM-yyyy}.log' -f (Get-Date) | |
$FilePath = Join-Path -Path $LogDirectory -ChildPath $FileName | |
# If the directory doesn't exist, create it. | |
if (-not(Test-Path $LogDirectory)) { | |
New-Item -ItemType Directory -Path $LogDirectory | |
} | |
if($PSBoundParameters.ContainsKey('LogDirectory')){ | |
$PSBoundParameters.Remove('LogDirectory') | |
} | |
# Ping it! | |
do { | |
Test-Connection @PSBoundParameters | Out-File $FilePath -Append -Force -Encoding default | |
} while ($true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment