Powershell Script to check the status of a website

8/12/2014 , 0 Comments

Here is  a script to check the status of a website

$HTTP_Request = [System.Net.WebRequest]::Create('http://www.blogger.co.nz')
$HTTP_Response = $HTTP_Request.GetResponse()
$HTTP_Status = [int]$HTTP_Response.StatusCode
If ($HTTP_Status -eq 200) {
    Write-Host $HTTP_Request.Host  "is OK!"
}
Else {
    Write-Host "The Site may be down, please check!"
}
$HTTP_Response.Close()
Output will be like  PS C:\\check-sparkdigitalwebsite.ps1

www.blogger.co.nz is OK!

0 comments :