I have this below script, but i just copied them from another script. I thought if I them on a single file or script, I would be able to get the output.
To be honest I don't have knowledge or skill with scripting, just copying and patse from the internet. Appreciate if you could help me please.
Private Function GetPercentFreeDiskSpace()
Dim colItems
Dim objItem
On Error Resume Next
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Volume where DriveLetter = 'C:'")
For Each objItem In colItems
GetPercentFreeDiskSpace = Round((objItem.FreeSpace / objItem.Capacity) * 100, 2)
Next
Err.Clear
End Function
Private Function GetMemoryUsage()
Dim colItems
Dim objItem
Dim localtime
On Error Resume Next
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem")
For Each objItem In colItems
GetMemoryUsage = Round(((objItem.TotalVisibleMemorySize - objItem.FreePhysicalMemory) / objItem.TotalVisibleMemorySize) * 100, 2)
SysUptime = objItem.LastBootUpTime
localtime = objItem.LocalDateTime
SysUptime = WMIDateStringToDate(SysUptime)
localtime = WMIDateStringToDate(localtime)
SysUptime = DateDiff("n", SysUptime, localtime)
SysUptime = timeConversion(SysUptime)
Next
Err.Clear
End Function
Private Function GetAverageCPULoad()
Dim colItems
Dim objItem
Dim ctr
Dim reading(4)
Dim total
On Error Resume Next
For ctr = 0 to 4
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor")
For Each objItem In colItems
If objItem.DeviceID = "CPU0" Then
reading(ctr) = objItem.LoadPercentage
End If
Next
WScript.Sleep 2000
Next
total = 0
For ctr = 0 to 4
total = total + reading(ctr)
Next
GetAverageCPULoad = total / 5
If Err.Number <> 0 Then
Err.Clear
GetAverageCPULoad = ""
End If
End Function
WScript.Echo "Avg. CPU Utilization (%)): " & values(0)
WScript.Echo "Memory Utilization (%): " & values(1)
WScript.Echo "C Drive Utilization (%): " & values(2)
WScript.Echo "System Uptime (hrs): " & values(3)
To be honest I don't have knowledge or skill with scripting, just copying and patse from the internet. Appreciate if you could help me please.
Private Function GetPercentFreeDiskSpace()
Dim colItems
Dim objItem
On Error Resume Next
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Volume where DriveLetter = 'C:'")
For Each objItem In colItems
GetPercentFreeDiskSpace = Round((objItem.FreeSpace / objItem.Capacity) * 100, 2)
Next
Err.Clear
End Function
Private Function GetMemoryUsage()
Dim colItems
Dim objItem
Dim localtime
On Error Resume Next
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem")
For Each objItem In colItems
GetMemoryUsage = Round(((objItem.TotalVisibleMemorySize - objItem.FreePhysicalMemory) / objItem.TotalVisibleMemorySize) * 100, 2)
SysUptime = objItem.LastBootUpTime
localtime = objItem.LocalDateTime
SysUptime = WMIDateStringToDate(SysUptime)
localtime = WMIDateStringToDate(localtime)
SysUptime = DateDiff("n", SysUptime, localtime)
SysUptime = timeConversion(SysUptime)
Next
Err.Clear
End Function
Private Function GetAverageCPULoad()
Dim colItems
Dim objItem
Dim ctr
Dim reading(4)
Dim total
On Error Resume Next
For ctr = 0 to 4
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor")
For Each objItem In colItems
If objItem.DeviceID = "CPU0" Then
reading(ctr) = objItem.LoadPercentage
End If
Next
WScript.Sleep 2000
Next
total = 0
For ctr = 0 to 4
total = total + reading(ctr)
Next
GetAverageCPULoad = total / 5
If Err.Number <> 0 Then
Err.Clear
GetAverageCPULoad = ""
End If
End Function
WScript.Echo "Avg. CPU Utilization (%)): " & values(0)
WScript.Echo "Memory Utilization (%): " & values(1)
WScript.Echo "C Drive Utilization (%): " & values(2)
WScript.Echo "System Uptime (hrs): " & values(3)