Created
December 11, 2015 00:47
-
-
Save chrisbrownie/8e81d969d2a4f5ccd29e to your computer and use it in GitHub Desktop.
Monitors a website's status
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
# 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