How to check programmatically if a sharepoint site is Up and running

Hi All,

I need to check if a Sharepoint internet facing site is UP and running . I need to do this programmatically since i need to check 60-70 sites in a small time.

The requirement is to get the URL of site and see if the site is loading successfully or not.

I have done something like this , but this script is sometime flagging the site down even it is up and running . [string] $url = http//mysite.com/Pages/home.aspx'

[net.httpWebRequest] $req = [net.webRequest]::create($url)
$req.Method = "HEAD"

[net.httpWebResponse] $res = $req.getResponse()

if ($res.StatusCode -ge "200") {
write-host "`nSite up`n" `
}

Any help in this matter will be greatly appreciated

Thanks,

Rohit

October 18th, 2013 9:54am

Well your status code will return a success on 500 messages, which are obviously errors. That'd give you a false 'up' message not a false down.

I suspect you might be hitting the site collection inital load time issue. Try running through your script, pausing 30 seconds and re-running. Do you get different results?


Free Windows Admin Tool Kit Click here and download it now
October 18th, 2013 10:07am

Hi Alex,

I am still getting Site down messages . Do i need to give complete URL with landing page mysite.com/pages/home.aspx  or just the URL like mysite.com

I am guessing the Script written by me is not an ideal way to test this scenario.

October 18th, 2013 10:39am

hi

yes, use full url. When you access site by short url, Sharepoint returns http 302 (moved temporarily) with link to the full url and browser redirects you to it. Also increase timeout for your request: Sharepoint sites may be warming up very long time.

Free Windows Admin Tool Kit Click here and download it now
October 18th, 2013 10:49am

Even with 50 Sec of delay , i am getting the Site Down notification.

Is there any way to log the IIS response when we hit the Sitecollection URL ?? if there is, can i leverage it using powershell?

October 18th, 2013 10:56am

A tool that has the ability to monitor websites (Site Scope, SCOM, etc.) would be my suggestion.
Free Windows Admin Tool Kit Click here and download it now
October 18th, 2013 4:44pm

Well your status code will return a success on 500 messages, which are obviously errors. That'd give you a false 'up' message not a false down.

I suspect you might be hitting the site collection inital load time issue. Try running through your script, pausing 30 seconds and re-running. Do you get different results?


October 18th, 2013 5:02pm

but did you try to load the same site collection in browser at the same time? Did it work? If yes, may be there is a problem in your code.

Also as another idea, check SharePoint Health Analyzer. It uses rules and reports available in object model, so it should be possible to reuse it in powershell.

Free Windows Admin Tool Kit Click here and download it now
October 21st, 2013 6:22am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics