Spot problem Windows Servers (automatic updates)

Spot problem Windows Servers (automatic updates)

If the Windows Server uptime is more than 30 days, then the server is a problem child. That’s a basic rule of thumb.

Windows Updates come out every month. Every month, a Window Server should be updated and rebooted. If it is not, then there is a problem.

One way to check for this is to match the current crop of updates to the applied updates on the server. This can take a bit of time and gives a better indication of the server state. A quicker way is to scan for Servers with uptime >= 30 days.

Below is a basic script that checks and reports the uptime. It’s trivial to modify into a problem child scanner.

Bonus tip: reboot your servers both before and after the updates. This minimizes problems applying the updates that may occur when files are open or processes are hung.

Happy patching.

 

‘—————————————————————–

‘ Name:   uptime.vbs

‘ Author: J Wolfgang Goerlich
‘ Date:   2005-05/07

‘ Description: Report uptime and possible concerns

‘—————————————————————–

Option Explicit

‘ Dimension variables

Dim wmi ‘ SWbemServices, WMI interface
Dim wns ‘ WMI namespace
Dim wql ‘ WMI Query Language
Dim computer
Dim oShell
Dim results
Dim os
Dim D, H, M, S

‘ Get the computer name

Set oShell = WScript.CreateObject(“WScript.Shell”)
if WScript.Arguments.UnNamed.Count >= 1 then
computer = Trim(LCase(WScript.Arguments(0)))
else
computer = LCase(oShell.ExpandEnvironmentStrings(“%ComputerName%”))
end if

‘ Get the uptime

wns = “winmgmts:\\” & computer & “\root\cimv2”
wql = “Select SystemUpTime From Win32_PerfFormattedData_PerfOS_System”

Set wmi = GetObject(wns)
Set results = wmi.ExecQuery(wql)

For Each os in results
S = os.SystemUpTime
Next

‘ Report the uptime and status

M = S \ 60 : S = S Mod 60 : H = M \ 60 : M = M Mod 60 : D = H \ 24
Wscript.Echo “Computer: ” & computer
Wscript.Echo “Uptime: ” & D & ” Days, ” & H Mod 24 & ” Hours, ” & M & ” Minutes”
If D >= 2 then Wscript.Echo “Problem child!”

Posted by