Skip to content

Instantly share code, notes, and snippets.

@DanElliott
Created March 1, 2024 20:17
Show Gist options
  • Save DanElliott/ad11ae7894a4d33ac89339477f77e002 to your computer and use it in GitHub Desktop.
Save DanElliott/ad11ae7894a4d33ac89339477f77e002 to your computer and use it in GitHub Desktop.
A PowerShell health check script
$urls = @("http://example.com", "http://example2.com") # Add the URLs you want to check here
foreach ($url in $urls) {
try {
$response = Invoke-WebRequest -Uri $url
if ($response.StatusCode -eq 200) {
Write-Host "Website $url is up and running."
} else {
Write-Host "Website $url is not responding properly. Status code: $($response.StatusCode)"
}
} catch {
Write-Host "An error occurred while checking the website url: $url"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment