Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pings server constantly and logs results.
#
# ConstantPingToArc.ps1
#
##This script purpose is to ping Arc console to monitor for network dropouts.
#Location for the log file
$testPath = Test-Path "C:\ping logs\"
#Manual on/off switch, if $onOff = $true means the loop is on, $false = its off.
$onOff = $true
$fileName = Get-Date -Format dd-MM-yyyy
$server = "abz-arcp01"
#if the file path is not their then it creates it.
if ($testPath -eq $true){while($onOff -eq $true){Test-Connection abz-arcp01 |Out-File "C:\ping logs\$filename.log" -Append -Force -encoding default}}else
{New-Item -ItemType directory -Path "C:\ping logs\"; while($onOff -eq $true){Test-Connection $server |Out-File "C:\ping logs\$filename.log" -Append -Force -encoding default}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.