none
any way to get around

    Question

  • we need to check several websites status.  I found this code and
    it worked great but it failed at some websites with untrusted cert such as
    https://server1
    (which does not have trusted certificate and you get warning "
    There is a problem with this website's security certificate.
    Continue to this website (not recommended)."

    Is there a way to check these internal websites with untrusted certificates also?
    Thank you!

    ------

    $URLListFile = "C:\URLList.txt" 
    $URLList = Get-Content $URLListFile -ErrorAction SilentlyContinue
      $Result = @()


      Foreach($Uri in $URLList) {
      $time = try{
      $request = $null

      $result1 = Measure-Command { $request = Invoke-WebRequest -Uri $uri }
      $result1.TotalMilliSeconds
      } 
      catch
      {

       $request = $_.Exception.Response
       $time = -1
      }  
      $result += [PSCustomObject] @{
      Time = Get-Date;
      Uri = $uri;
      StatusCode = [int] $request.StatusCode;
      StatusDescription = $request.StatusDescription;
      ResponseLength = $request.RawContentLength;
      TimeTaken =  $time; 
      }

    }

    if($result -ne $null)
    {
        $Outputreport = "<HTML><TITLE>Website Report Status</TITLE><BODY background-color:peachpuff><font color

    =""#99000"" face=""Microsoft Tai le""><H2> Website Report Status </H2></font><Table border=1 cellpadding=0

    cellspacing=0><TR bgcolor=gray align=center><TD><B>URL</B></TD><TD><B> Code </B></TD><TD><B> Status

    </B></TD><TD><B> Duration </B></TD><TD><B> MS (Ping) </B></TD</TR>"
        Foreach($Entry in $Result)
        {
            if($Entry.StatusCode -ne "200")
            {
               $Outputreport += "<TR bgcolor=red>"
            }
            else
            {
                $Outputreport += "<TR>"
            }
            $Outputreport += "<TD>$($Entry.uri)</TD><TD align=center>$($Entry.StatusCode)</TD><TD align=center>

    $($Entry.StatusDescription)</TD><TD align=center>$($Entry.ResponseLength)</TD><TD align=center>$($Entry.timetaken)

    </TD></TR>"
        }
        $Outputreport += "</Table></BODY></HTML>"
    }

    $Outputreport | out-file C:\URLReport.htm
    Invoke-Item C:\URLReport.htm  

    ----------

    Tuesday, November 12, 2013 4:03 PM

Answers

All replies