Created
September 23, 2023 14:05
-
-
Save rossarioking/e697ea8ff80810ca1c419585c3db89a9 to your computer and use it in GitHub Desktop.
Monitoring Website Availability with Powershell
This file contains 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
$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