Hello All,
I hope you guys can help me out. I am building powershell script that checks the status of websites that is pulled from a text file names URLS.txt and displays if it is up or down. that works great! However, I am now trying to get it to do a convertto-html and have the results show up in internet explorer. I can not seem to get this to work. I can invoke the html it is outputting to but it is either the wrong data or nothing at all. I have tried different areas as well still no luck. I am only looking for the url it is checking (i think it is the responseuri) and the status of the site like in my code. I also want it in the same page showing all the results of the urls on one page.
Thanks in advance..
I hope you guys can help me out. I am building powershell script that checks the status of websites that is pulled from a text file names URLS.txt and displays if it is up or down. that works great! However, I am now trying to get it to do a convertto-html and have the results show up in internet explorer. I can not seem to get this to work. I can invoke the html it is outputting to but it is either the wrong data or nothing at all. I have tried different areas as well still no luck. I am only looking for the url it is checking (i think it is the responseuri) and the status of the site like in my code. I also want it in the same page showing all the results of the urls on one page.
Code:
#WebChecker.ps1
TRAP { CONTINUE }
$urls = Get-Content C:\URLS.txt # -Exclude ("-")
Invoke-item C:\Scripts\WebChecker_Report.html
function CheckSiteStatus()
{
$req = [System.Net.WebRequest]::Create($url)
try
{
$res = $req.GetResponse()
IF ($Res.StatusCode -eq "OK") {
Write-Host -foregroundcolor Gray $url -NoNewline; Write-Host -foreground GREEN " UP"
}
Write-Host ""
}
catch
{
IF
($Res.StatusCode -ne "OK") {
Write-Host -foregroundcolor Gray $url -NoNewline; Write-Host -foreground Red " WARNING!..DOWN"
}
Write-Host ""
}
}
FOREACH ($url IN $urls)
{
$url|ConvertTo-Html|Out-File C:\Scripts\WebChecker_Report.html
CheckSiteStatus
}
Thanks in advance..