Skip to content

Instantly share code, notes, and snippets.

@chrisbrownie
Created December 11, 2015 00:47
Show Gist options
  • Save chrisbrownie/8e81d969d2a4f5ccd29e to your computer and use it in GitHub Desktop.
Save chrisbrownie/8e81d969d2a4f5ccd29e to your computer and use it in GitHub Desktop.
Monitors a website's status
# Site to check
$site = "https://www.github.com"
# Seconds between checks
$interval = 2
while ($true) {
$result = try { Invoke-WebRequest $site -ErrorAction silentlycontinue } catch { $null }
if ($result.statuscode -eq 200) {
Write-Host "$site is up" -BackgroundColor green -ForegroundColor white
} else {
Write-Host "$site is down" -BackgroundColor red -ForegroundColor white
}
Start-Sleep $interval
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment