Uptime Scanner
[source language="vb"]</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
[/source]