Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Check web site availability

$
0
0

Hi i manage a few internal sites like

$sites = site1.mycompany.com , site2.mycompany.com , site3.mycompany.com 

I would like to monitor them and make sure they are up.

What is the best way to do this?

foreach ($site in $sites) {

$web = Invoke-WebRequest -Uri $site

}

I can look into the $web.statuscode and if -eq "200", and  $$web.Statusdescription -eq "OK" this means that the page is fine, correct?

But if i try to query a wrong site it fails, i still get a code 200 and description OK.

So i guess this is not a proper way? 

Thanks



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>