Skip to content

Instantly share code, notes, and snippets.

@notmayo
Last active February 27, 2019 16:28
Show Gist options
  • Save notmayo/278fd8c57b3bc1b1dc5949555a3b9711 to your computer and use it in GitHub Desktop.
Save notmayo/278fd8c57b3bc1b1dc5949555a3b9711 to your computer and use it in GitHub Desktop.
Create a clients.txt file with one ip/hostname per line
set-executionpolicy unrestricted
clear
while($true)
{
$PingMachines = Gc "clients.txt"
ForEach($MachineName In $PingMachines)
{$PingStatus = Gwmi Win32_PingStatus -Filter "Address = '$MachineName'" |
Select-Object StatusCode
If ($PingStatus.StatusCode -eq 0)
{Write-Host $MachineName -Fore "Green"}
Else
{Write-Host $MachineName -Fore "Red"}}
echo -----
start-sleep -seconds 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment