Created
March 1, 2024 20:17
-
-
Save DanElliott/ad11ae7894a4d33ac89339477f77e002 to your computer and use it in GitHub Desktop.
A PowerShell health check script
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
$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