Hi there
I'm trying to use the following script to give me a report on Server Uptime and I can get it to work using a single instance but can't get it to read the MachineList.Txt file
Can anyone help.
Cheers
strComputer = "MachineList.Txt"
'strComputer = InputBox("Enter Machine Name")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=imper
sonate}!\\
" & strComputer & "\root\cimv2")
Set objExcel = CreateObject("Excel.Applic
ation")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Machine Name"
objExcel.Cells(1, 2).Value = "IP Address"
objExcel.Cells(1, 3).Value = "MAC Address"
objExcel.Cells(1, 4).Value = "Days"
objExcel.Cells(1, 5).Value = "Hours"
objExcel.Cells(1, 6).Value = "Minutes"
objExcel.Cells(1, 7).Value = "Report Time Stamp"
Set colAdapters = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfig
uration WHERE IPEnabled = True")
For Each objAdapter in colAdapters
objExcel.Cells(intRow, 1).Value = objAdapter.DNSHostName
If Not IsNull(objAdapter.IPAddres
s) Then
For i = 0 To UBound(objAdapter.IPAddres
s)
objExcel.Cells(intRow, 2).Value = objAdapter.IPAddress(i)
Next
End If
objExcel.Cells(intRow, 3).Value = objAdapter.MACAddress
Next
Set colObjects = objWMIService.ExecQuery ("SELECT * FROM Win32_PerfRawData_PerfOS_S
ystem")
For Each objWmiObject In colObjects
intPerfTimeStamp = objWmiObject.Timestamp_Obj
ect
intPerfTimeFreq = objWmiObject.Frequency_Obj
ect
intCounter = objWmiObject.SystemUpTime
Next
iUptimeInSec = (intPerfTimeStamp - intCounter)/intPerfTimeFre
q
sUptime = ConvertTime(iUptimeInSec)
Function ConvertTime(seconds)
ConvDays = seconds \ (3600 * 24)
ConvHour = (seconds Mod (3600 * 24)) \ 3600
ConvMin = (seconds Mod 3600) \ 60
objExcel.Cells(intRow, 4).Value = ConvDays
objExcel.Cells(intRow, 5).Value = ConvHour
objExcel.Cells(intRow, 6).Value = ConvMin
End Function
objExcel.Cells(intRow, 7).Value = Now()
intRow = intRow + 1
objExcel.Range("A1:G1").Se
lect
objExcel.Selection.Interio
r.ColorInd
ex = 19
objExcel.Selection.Font.Co
lorIndex = 11
objExcel.Selection.Font.Bo
ld = True
objExcel.Cells.EntireColum
n.AutoFit
Set objWMIService = Nothing
Set objExcel = Nothing
Set colAdapters = Nothing
Set colObjects = Nothing
Wscript.Echo "Done"
Start Free Trial