|
Latest restart time and latest installed windows update time to HT How could i get server names from txt file and put the latest restart time
and latest installed windows update time to HTML file?
I have a script that gets server names from txt file, pings servers and puts
the result (pinging server name with green and not pinging server name with
red) to HTML file. Could it be done similarly?
Here is my current script:
clear
$pingResults =("E:\PingResults.htm")
$RunDate = (get-date).tostring("dd.MM.yyyy")
$PingTime = (Get-Date -format 'hh:mm')
#Write the preamble of the report
Clear-Content “E:\PingResults.htm”
Add-Content -Path $pingResults ("<!DOCTYPE HTML PUBLIC -//W3C//DTD
HTML 4.0//EN http://www.w3.org/TR/REC-html40/strict.dtd>")
Add-Content -Path $pingResults ("<html> <p>")
Add-Content -Path $pingResults ("<head> <p>")
Add-Content -Path $pingResults ("<title> Ping Results </title>")
Add-Content -Path $pingResults ("</head>")
Add-Content -Path $pingResults ("<b><FONT size=2 face=arial>Pingi
Monitooring - " + $RunDate + " , kell " + $PingTime + "</b></font><p>")
$PingMachines = Gc "E:\MachineList.txt"
ForEach($MachineName In $PingMachines)
{$PingStatus = Gwmi Win32_PingStatus -Filter "Address = '$MachineName'" |
Select-Object StatusCode
If ($PingStatus.StatusCode -eq 0)
{Add-Content -Path $pingResults ("<FONT size=2 face=arial>Server:
</font><b><FONT face=arial size=2 color = #00FF00>" + $MachineName +
"</FONT></b><br>")}
Else
{Add-Content -Path $pingResults ("<FONT size=2 face=arial>Server:
</font><b><FONT face=arial size=2 color = #FF0000>" + $MachineName +
"</FONT></b>")
Add-Content -Path $pingResults ("<br>")}
} |