Howdy,
I am trying to use a script I found on a forum for monitoring a website. The issue I have is that the site requires ad creds and then once you login, the page you land on is not the page I have to verify, although that would be good to do..
Once the login succeeds there is a page that is just static info and then there is a link that you click to go to the page that runs an application. I need to monitor this app and I'm stuck on how to get the login to work and then to go to that next page, and alert if that page has an error code.
Can anyone help?
This was found on Isaacblum.com for the proper credit!
function siteupdown{## Display Helpif(($Args[0]-eq"-?")-or($Args[0]-eq"-help")){"""Usage: SysinternalsSiteTest.ps1 -alert<address> -log"" -alert<address> Send e-mail alerts"" -log Log results""""Example: SysinternalsSiteTest.ps1 -alert somebody@nospam.com -log""" exit} ## Create the variables$global:GArgs =$Args $urlsToTest=@{}$urlsToTest["SP2010"]="http://sp2010/Pages/default.aspx"## Add more URLs for monidoting **Note URL cannot be rediriecting urls.#$urlsToTest["TechNet Redirect"] = "http://www.microsoft.com/sysinternals"#$urlsToTest["Sysinternals Home"] = "http://www.microsoft.com/technet/sysinternals/default.mspx"#$urlsToTest["Sysinternals Forum"] = "http://forum.sysinternals.com"#$urlsToTest["Sysinternals Blog"] = "http://blogs.technet.com/sysinternals"#$urlsToTest["Sysinternals Downloads"] = "http://download.sysinternals.com/Files/NtfsInfo.zip" $successCriteria=@{}$successCriteria["SP2010"]="*press releases*"## Add more success criteria here.#$successCriteria["TechNet Redirect"] = "*Mark Russinovich*"#$successCriteria["Sysinternals Home"] = "*Mark Russinovich*"#$successCriteria["Sysinternals Forum"] = "*Sysinternals Utilities*"#$successCriteria["Sysinternals Blog"] = "*Sysinternals Site Discussion*"#$successCriteria["Sysinternals Downloads"] = "*ntfsinfo.exe*" ## Set Username Password and domain here$Username='be'$Password='password!!!1'$Domain='gen' ## sets up the call$webClient=new-object System.Net.WebClient$webClient.credentials =New-Object System.Net.NetworkCredential($Username,$Password,$Domain) foreach($keyin$urlsToTest.Keys){$alert=$false$output="" $startTime=get-date$output=$webClient.DownloadString($urlsToTest[$key])$endTime=get-date if($output-like$successCriteria[$key]){$key+"`t`tSuccess`t`t"+$startTime.DateTime +"`t`t"+($endTime-$startTime).TotalSeconds +" seconds" if($GArgs-eq"-log"){$key+"`t`tSuccess`t`t"+$startTime.DateTime +"`t`t"+($endTime-$startTime).TotalSeconds +" seconds">> WebSiteTest.log}}else{$key+"`t`tFail`t`t"+$startTime.DateTime +"`t`t"+($endTime-$startTime).TotalSeconds +" seconds"$alert=$trueif($GArgs-eq"-log"){$key+"`t`tFail`t`t"+$startTime.DateTime +"`t`t"+($endTime-$startTime).TotalSeconds +" seconds">> WebSiteTest.log$alert=$true} if($alert-eq$true){Write-Host"Sending Email"## Set email settings Below. $emailFrom, $EmailTo, $smtpServer$emailFrom="email@nospam.com"$emailTo="email@nospam.com"$subject="URL Test Failure - "+$startTime$body="URL Test Failure: "+$key+" ("+$urlsToTest[$key]+") at "+$startTime$smtpServer="smtp.nospam.com"$smtp=new-object Net.Mail.SmtpClient($smtpServer)$smtp.Send($emailFrom,$emailTo,$subject,$body)}}}}## Makes the script run forever.$i=1for($i-le5; $i++){## Change the number, to change check site interval. 1 = 1 seconds, 30 = 30 seconds, etc..sleep30; siteupdown}</address></address>