Last active
February 28, 2019 16:16
-
-
Save notmayo/212735c96fb0e573d26e1713ac658915 to your computer and use it in GitHub Desktop.
Ping status script that does not require a separate txt file.
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
set-executionpolicy unrestricted | |
clear | |
while($true) | |
{ | |
$date = Get-Date | |
$sleep = 10 | |
$Tab = [char]9 | |
Write-Host -Fore "Blue" "Ping status $date" | |
Write-Output ----- | |
$PingCommercial = "8.8.8.8" | |
ForEach($MachineName In $PingCommercial) | |
{$PingStatus = Gwmi Win32_PingStatus -Filter "Address = '$MachineName'" | | |
Select-Object StatusCode | |
If ($PingStatus.StatusCode -eq 0) | |
{Write-Host Commercial: $($tab)$($tab) $MachineName $($tab)$($tab) Connection successful -Fore "Green"} | |
Else | |
{Write-Host Commercial: $($tab)$($tab) $MachineName $($tab)$($tab) Connection failure -Fore "Red"}} | |
$PingNIPR = "www.my.af.mil" | |
ForEach($MachineName In $PingNIPR) | |
{$PingStatus = Gwmi Win32_PingStatus -Filter "Address = '$MachineName'" | | |
Select-Object StatusCode | |
If ($PingStatus.StatusCode -eq 0) | |
{Write-Host NIPR: $($tab) $($tab)$($tab) $MachineName $($tab)$($tab) Connection successful -Fore "Green"} | |
Else | |
{Write-Host NIPR: $($tab) $($tab)$($tab) $MachineName $($tab)$($tab) Connection failure -Fore "Red"}} | |
$PingNMS = "172.30.14.6" | |
ForEach($MachineName In $PingNMS) | |
{$PingStatus = Gwmi Win32_PingStatus -Filter "Address = '$MachineName'" | | |
Select-Object StatusCode | |
If ($PingStatus.StatusCode -eq 0) | |
{Write-Host SATCOM NMS: $($tab)$($tab) $MachineName $($tab)$($tab) Connection successful -Fore "Green"} | |
Else | |
{Write-Host SATCOM NMS: $($tab)$($tab) $MachineName $($tab)$($tab) Connection failure -Fore "Red"}} | |
Write-Output ----- | |
Write-Host -Fore "White" "Waiting $($sleep) second(s)" | |
Write-Output " " | |
start-sleep -seconds $sleep | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment