Created
March 7, 2014 22:23
-
-
Save anroots/9421460 to your computer and use it in GitHub Desktop.
A PowerShell script that pings a list of static IP-s to determine the UP / DOWN status of each IP
This file contains hidden or 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
# A PowerShell script to check the status (online / offline) of NODE-s | |
# Pings each NODE with a ICMP packet to get its status | |
# | |
# Author Ando Roots <[email protected]> 2014-03-05 | |
# -------------- CONFIG ------------------- # | |
# Node numbers to ping | |
$NodeList = 11,12,13,14,15,16,17,18,24 | |
# How many pings to each node. The status is DOWN if any of them fail. | |
$PingCount = 2 | |
# Time to Live for the ping packets | |
$TTL = 5 | |
# ------------ END CONFIG ----------------- # | |
echo "" | |
date | |
echo "NODE status check started" | |
echo "" | |
$Percent = 10 | |
$SuccessCounter = 0 | |
foreach ($Node in $NodeList) { | |
# Full NODE IP to ping (CISCO gateway) | |
$IP = "10.54."+$Node+".62" | |
# Progress window | |
write-progress -activity "Testing NODE Links..." -status "$Percent% complete" -percentcomplete $Percent -currentOperation "connecting to N$Node..." | |
# Ping NODE, save output (bool) to a var | |
$IsOnline = test-connection ($IP) -count $PingCount -Quiet -TimeToLive $TTL | |
if ($IsOnline) { | |
echo "N$Node is UP" | |
$SuccessCounter += 1 | |
} else { | |
echo "N$Node is DOWN!" | |
} | |
$Percent += 10 | |
} | |
echo "-----------------" | |
# Show summary | |
$NodeCount = $NodeList.length | |
$UPPercent = $SuccessCounter*100/$NodeList.length | |
echo "$SuccessCounter of $NodeCount UP ($UPPercent%)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment