Uptime Scanner

Uptime Scanner

</pre>
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const CONVERT_TO_LOCAL_TIME = True

Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
CurrentDirectory = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))
Set DeviceListFile = FileSystemObject.OpenTextFile(CurrentDirectory & "\serverlistall.txt", ForReading)

Do Until DeviceListFile.AtEndOfStream
 Devicename = DeviceListFile.ReadLine
 If Trim(Devicename) <> "" Then
 Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
 dtmStartDate.SetVarDate dateadd("n", -10, now)' CONVERT_TO_LOCAL_TIME

Set winmgmts = GetObject("winmgmts:\\" & Devicename & "\root\cimv2")
 Set Win32_OperatingSystem = winmgmts.ExecQuery ("Select * from Win32_OperatingSystem")
 For each Instance in Win32_OperatingSystem
 Wscript.Echo Devicename & ", " & UtcDateToString(Instance.LastBootUpTime)
 Next
 End if
Loop
DeviceListFile.Close

Function UtcDateToString(UtcFormattedDate)
 UtcDateToString = CDate(Mid(UtcFormattedDate, 5, 2) & "/" & Mid(UtcFormattedDate, 7, 2) & "/" & Left(UtcFormattedDate, 4) & " " & Mid (UtcFormattedDate, 9, 2) & ":" & Mid(UtcFormattedDate, 11, 2) & ":" & Mid(UtcFormattedDate, 13, 2))
End Function

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s