Yes,still using VB :) attached the script tells the last uptime date and number
of hours since Online.
Eswar Koneti
www.eskonr.com
From: [email protected]
To: [email protected]
Subject: RE: [mssms] Uptime for List of Servers
Date: Thu, 12 Sep 2013 11:57:32 -0400
Had to check the date. VB Script? J Here’s a PowerShell script
http://myitforum.com/myitforumwp/2011/11/08/powershell-script-to-get-server-last-reboot-time/
From: [email protected] [mailto:[email protected]]
On Behalf Of Eswar Koneti
Sent: Thursday, September 12, 2013 11:38 AM
To: [email protected]
Subject: RE: [mssms] Uptime for List of Servers I use vbscrpt with input list
of servers to get it. Chances of servers may not report its inventory in time
or if inventory schdule is long.
Regards,
Eswar Koneti
Www.eskonr.com
--- Original Message ---
From: "Marcum, John" <[email protected]>
Sent: September 12, 2013 10:59 PM
To: "SMS List ([email protected])" <[email protected]>
Subject: [mssms] Uptime for List of ServersWhat's the easiest way to get the
last reboot time for a list of servers? John Marcum
Sr. Desktop ArchitectBradley Arant Boult Cummings LLP
Confidentiality Notice: This e-mail is from a law firm and may be protected by
the attorney-client or work product privileges. If you have received this
message in error, please notify the sender by replying to this e-mail and then
delete it from your computer.
On Error Resume Next
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\scripts\servers.txt", ForReading)
Set outfile = objFSO.CreateTextFile("Report.txt")
Do Until objTextFile.AtEndOfStream
strComputer = objTextFile.Readline
Set objWMIService = GetObject ("winmgmts:\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOS in colOperatingSystems
dtmBootup = objOS.LastBootUpTime
dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
dtmSystemUptime = DateDiff("h", dtmLastBootUpTime, Now)
OutFile.WriteLine "Computer: " &strComputer & vbtab & "Last Reboot: " &
dtmLastBootupTime & vbtab & "onlinesince:" & dtmSystemUptime & " hours"
Next
Loop
objTextFile.Close
MsgBox "Script Execution Completed. The Report is saved as Report.txt in the
current directory"
Function WMIDateStringToDate(dtmBootup)
WMIDateStringToDate = CDate(Mid(dtmBootup, 5, 2) & "/" & _
Mid(dtmBootup, 7, 2) & "/" & Left(dtmBootup, 4) _
& " " & Mid (dtmBootup, 9, 2) & ":" & _
Mid(dtmBootup, 11, 2) & ":" & Mid(dtmBootup, _
13, 2))
End Function