Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: General » microsoft.public.windows.powershell
Thread: Latest restart time and latest installed windows update time to HT

HTVi
TV Discussion Newsgroups

Latest restart time and latest installed windows update time to HT
Eero J 12/29/2008 9:28:00 AM
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>")}
}
RE: Latest restart time and latest installed windows update time to HT
RichS [MVP] 12/30/2008 7:31:01 PM
To get the date of the latest installed update

Get-WmiObject -Class Win32_QuickFixEngineering | Sort InstalledOn
-Descending | Select InstalledOn -First 1

you can add a -computername to direct get-wmiobject to the correct machine
--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Eero J" wrote:

[Quoted Text]
> 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>")}
> }
RE: Latest restart time and latest installed windows update time to HT
RichS [MVP] 12/30/2008 7:39:19 PM
Missed the last restart time

$t1 = Get-WmiObject -Class Win32_OperatingSystem
$t1.ConvertToDateTime($t1.LastBootUpTime)

again use -computrname for remote machines
--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Eero J" wrote:

[Quoted Text]
> 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>")}
> }
Re: Latest restart time and latest installed windows update time to HT
OldDog <mikef2691[ at ]comcast.net> 12/30/2008 8:28:55 PM
On Dec 30, 1:39 pm, RichS [MVP] <RichS...[ at ]discussions.microsoft.com>
wrote:
[Quoted Text]
> Missed the last restart time
>
> $t1 = Get-WmiObject -Class Win32_OperatingSystem
> $t1.ConvertToDateTime($t1.LastBootUpTime)
>
> again use -computrname for remote machines
> --
> Richard Siddaway
> All scripts are supplied "as is" and with no warranty
> PowerShell MVP
> Blog:http://richardsiddaway.spaces.live.com/
> PowerShell User Group:http://www.get-psuguk.org.uk
>
>
>
> "Eero J" wrote:
> > 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//ENhttp://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>")}
> > }- Hide quoted text -
>
> - Show quoted text -

So with all that in mind:

# Red = #FF0000
# Green = #00FF00
# Blue = #0000FF
# Cyan (blue and green) = #00FFFF
# Magenta (red and blue) = #FF00FF
# Yellow (red and green) = #FFFF00

clear
$pingResults =("C:\Scripts\PingResults\pingResults.HTM")
$RunDate = (get-date).tostring("MM_dd_yyyy")
$PingTime = (Get-Date -format 'hh:mm')


#Write the preamble of the report
Set-Content -Path $pingResults ("<!DOCTYPE HTML PUBLIC -//W3C//DTD
HTML 4.0//EN http://www.w3.org/TR/REC-html40/strict.dtd>")
Set-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 ("<h3>Report Generated " + $RunDate + "
[ at ] " + $PingTime + "</h3> <p>")

$PingMachines = Gc "C:\MachineList.txt"
ForEach($MachineName In $PingMachines)
{$PingStatus = Gwmi Win32_PingStatus -Filter "Address =
'$MachineName'" |
Select-Object StatusCode
If ($PingStatus.StatusCode -eq 0) {
$wmi = gwmi -Class Win32_OperatingSystem -ErrorAction
silentlycontinue -ComputerName $MachineName
$lastBootTime = $wmi.ConvertToDateTime($wmi.LastBootUpTime)
$t1 = Get-WmiObject -Class Win32_QuickFixEngineering -ErrorAction
silentlycontinue -ComputerName $MachineName | Sort InstalledOn -
Descending | Select InstalledOn -First 1

Add-Content -Path $pingResults ("<pre><h3>Server Name: <FONT color =
#00FF00>" + $MachineName + "</FONT></h3> Last Boot Time: " +
$lastBootTime + " Latest installed update: " + $t1 + "</pre>")
$lastBootTime = " " }

Else {
Add-Content -Path $pingResults ("<pre><h3>Server Name: <FONT color =
#FF0000>" + $MachineName + "</FONT></h3></pre>")}
}

And as usual, watch the wrap
Re: Latest restart time and latest installed windows update time to HT
OldDog <mikef2691[ at ]comcast.net> 12/30/2008 10:34:25 PM
On Dec 30, 2:28 pm, OldDog <mikef2...[ at ]comcast.net> wrote:
[Quoted Text]
> On Dec 30, 1:39 pm, RichS [MVP] <RichS...[ at ]discussions.microsoft.com>
> wrote:
>
>
>
>
>
> > Missed the last restart time
>
> > $t1 = Get-WmiObject -Class Win32_OperatingSystem
> > $t1.ConvertToDateTime($t1.LastBootUpTime)
>
> > again use -computrname for remote machines
> > --
> > Richard Siddaway
> > All scripts are supplied "as is" and with no warranty
> > PowerShell MVP
> > Blog:http://richardsiddaway.spaces.live.com/
> > PowerShell User Group:http://www.get-psuguk.org.uk
>
> > "Eero J" wrote:
> > > 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//ENhttp://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>")}
> > > }- Hide quoted text -
>
> > - Show quoted text -
>
> So with all that in mind:
>
> # Red = #FF0000
> # Green = #00FF00
> # Blue = #0000FF
> # Cyan (blue and green) = #00FFFF
> # Magenta (red and blue) = #FF00FF
> # Yellow (red and green) = #FFFF00
>
> clear
> $pingResults =("C:\Scripts\PingResults\pingResults.HTM")
> $RunDate  = (get-date).tostring("MM_dd_yyyy")
> $PingTime = (Get-Date -format 'hh:mm')
>
> #Write the preamble of the report
> Set-Content -Path $pingResults ("<!DOCTYPE HTML PUBLIC -//W3C//DTD
> HTML 4.0//ENhttp://www.w3.org/TR/REC-html40/strict.dtd>")
> Set-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 ("<h3>Report Generated " + $RunDate + "
> [ at ] " + $PingTime + "</h3> <p>")
>
> $PingMachines = Gc "C:\MachineList.txt"
> ForEach($MachineName In $PingMachines)
> {$PingStatus = Gwmi Win32_PingStatus -Filter "Address =
> '$MachineName'" |
> Select-Object StatusCode
> If ($PingStatus.StatusCode -eq 0) {
>         $wmi = gwmi -Class Win32_OperatingSystem -ErrorAction
> silentlycontinue -ComputerName $MachineName
>         $lastBootTime = $wmi.ConvertToDateTime($wmi.LastBootUpTime)
>         $t1 = Get-WmiObject -Class Win32_QuickFixEngineering -ErrorAction
> silentlycontinue -ComputerName $MachineName | Sort InstalledOn -
> Descending | Select InstalledOn -First 1
>
>         Add-Content -Path $pingResults ("<pre><h3>Server Name: <FONT color =
> #00FF00>" + $MachineName + "</FONT></h3> Last Boot Time: " +
> $lastBootTime + " Latest installed update: " + $t1 + "</pre>")
>         $lastBootTime = " "             }
>
> Else {
> Add-Content -Path $pingResults ("<pre><h3>Server Name: <FONT color =
> #FF0000>" + $MachineName + "</FONT></h3></pre>")}
>          }
>
> And as usual, watch the wrap- Hide quoted text -
>
> - Show quoted text -

Woops:

Set-Content -Path $pingResults ("<html> <p>")

Sould be:

Add-Content -Path $pingResults ("<html> <p>")
Re: Latest restart time and latest installed windows update time to HT
OldDog <mikef2691[ at ]comcast.net> 12/30/2008 10:37:59 PM
On Dec 30, 1:39 pm, RichS [MVP] <RichS...[ at ]discussions.microsoft.com>
wrote:
[Quoted Text]
> Missed the last restart time
>
> $t1 = Get-WmiObject -Class Win32_OperatingSystem
> $t1.ConvertToDateTime($t1.LastBootUpTime)
>
> again use -computrname for remote machines
> --
> Richard Siddaway
> All scripts are supplied "as is" and with no warranty
> PowerShell MVP
> Blog:http://richardsiddaway.spaces.live.com/
> PowerShell User Group:http://www.get-psuguk.org.uk
>
>
>
> "Eero J" wrote:
> > 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//ENhttp://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>")}
> > }- Hide quoted text -
>
> - Show quoted text -

So with all that being said:

# Red = #FF0000
# Green = #00FF00
# Blue = #0000FF
# Cyan (blue and green) = #00FFFF
# Magenta (red and blue) = #FF00FF
# Yellow (red and green) = #FFFF00

clear
$pingResults =("C:\Scripts\PingResults\pingResults.HTM")
$RunDate = (get-date).tostring("MM_dd_yyyy")
$PingTime = (Get-Date -format 'hh:mm')


#Write the preamble of the report
Set-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 ("<h3>Report Generated " + $RunDate + "
[ at ] " + $PingTime + "</h3> <p>")

$PingMachines = Gc "C:\MachineList.txt"
ForEach($MachineName In $PingMachines)
{$PingStatus = Gwmi Win32_PingStatus -Filter "Address =
'$MachineName'" |
Select-Object StatusCode
If ($PingStatus.StatusCode -eq 0) {
$wmi = gwmi -Class Win32_OperatingSystem -ErrorAction
silentlycontinue -ComputerName $MachineName
$lastBootTime = $wmi.ConvertToDateTime($wmi.LastBootUpTime)
$t1 = Get-WmiObject -Class Win32_QuickFixEngineering -ErrorAction
silentlycontinue -ComputerName $MachineName | Sort InstalledOn -
Descending | Select InstalledOn -First 1

Add-Content -Path $pingResults ("<pre><h3>Server Name: <FONT color =
#00FF00>" + $MachineName + "</FONT></h3> Last Boot Time: " +
$lastBootTime + " Latest installed update: " + $t1 + "</pre>")
$lastBootTime = " " }

Else {
Add-Content -Path $pingResults ("<pre><h3>Server Name: <FONT color =
#FF0000>" + $MachineName + "</FONT></h3></pre>")}
}

< ---------- End Script ---------------->

Watch the wrap!

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen