SP Website availabity PS script returns undesired results

This topic contains 1 reply, has 2 voices, and was last updated by  Vern Anderson 4 years, 4 months ago.

  • Author
  • #12741

    Reyn Ackon

    I have a PS script which monitors the availability of my SharePoint 2007 websites. The script also emails me if any of the SharePoint urls isn't loading or isn't up. I'm monitoring four sharepoint websites. If I ping a site that I don't have access to, I receive a 401 unauthorized error. The site is up it's just that I don't have access to the site. I understand why I receive the error, but I would like to bypass that somehow. I would like to tweak my code that shows a ping success for an url even though the url displays a http 401 unathorized message. Any ideas?

    do {
    function Test-Site { param($URL)
    "Failed. Details: $($_.Exception)"
    Write-Host "Sending email notification."
    # if the ping is unsuccessful the following line will pause the script for n seconds, so that we do not get multiple emails
    Start-Sleep -s 3600}
    $webclient = New-Object Net.WebClient
    # The next 5 lines are required as our network has a proxy server
    $webclient.Credentials = [System.Net.CredentialCache]::DefaultCredentials
    if($webclient.Proxy -ne $null) {
    $webclient.Proxy.Credentials = `
    # This is the main call
    $webclient.DownloadString($URL) | Out-Null
    Test-Site "http://dev.sample.com"
    Test-Site "http://dev.sample.com:81"
    Test-Site "(http)://dev.sample.com:845"
    Test-Site "(http)://dev.sample.com:11"
    $response = "Y"
    while ($response -eq "Y")

    Also, I don't have any access to http://dev.sample.com:81 but when I ping this server, I don't receive any error messages. Any ideas?

  • #12758

    Vern Anderson

    You need http://www.toddklindt.com/default.aspx Todd Klindt he may even have some scripts already on his blog that do what you need to do.


You must be logged in to reply to this topic.