Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rossarioking/e697ea8ff80810ca1c419585c3db89a9 to your computer and use it in GitHub Desktop.
Save rossarioking/e697ea8ff80810ca1c419585c3db89a9 to your computer and use it in GitHub Desktop.
Monitoring Website Availability with Powershell
$websites = "https://example.com", "https://google.com"
$websites | ForEach-Object {
$url = $_
$response = Invoke-WebRequest -Uri $url
if ($response.StatusCode -eq 200) {
Write-Host "$url is online (Status Code: $($response.StatusCode))"
}
else {
Write-Host "$url is down (Status Code: $($response.StatusCode))"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment