Hi all,
I need to monitor web page availability. And this page is only accessed from a specific server. So I can't use http or https monitor. And I have decided to use Powershell monitor. But the problem is, this page uses authentication. So my scripts don't work correctly. Please share any advice.
Thank you in advice!
$HTTP_Request = [System.Net.WebRequest]::Create('http://SomePage.asmx')
$HTTP_Response = $HTTP_Request.GetResponse()
$HTTP_Status = [int]$HTTP_Response.StatusCode
If ($HTTP_Status -eq 401) {
Write-Host "statistic: 1"
}
Else {
Write-Host "statistic: 0"
}
#
$HTTP_Response.Close()