Skip to content

Instantly share code, notes, and snippets.

@tombasche
Created January 9, 2017 02:23
Show Gist options
  • Save tombasche/d72cf0c4c08d0460b4fccad3725bee3e to your computer and use it in GitHub Desktop.
Save tombasche/d72cf0c4c08d0460b4fccad3725bee3e to your computer and use it in GitHub Desktop.
param (
[Parameter(Mandatory=$true)][string]$Hostname
)
$failure = ""
while (!$failure) {
try {
$net = [System.Net.Dns]::GetHostAddresses($Hostname)
$Host.UI.RawUI.BackgroundColor = ($bckgrnd = 'DarkGreen')
} catch [Exception] {
$failure = "yes"
$Host.UI.RawUI.BackgroundColor = ($bckgrnd = 'Red')
return $_.Exception.Message
}
$ping = new-object system.net.networkinformation.ping
$ping.send($Hostname)
Start-Sleep -s 1
Clear-Host
}
@tombasche
Copy link
Author

NB. may need to run 'Set-ExecutionPolicy Unrestricted' in an admin window

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment