Friday, May 29, 2009

WSUS 3.0 SP2 Upgrade from SP1

I ran an in-place upgrade of my WSUS 3.0 server from SP1 to SP2 RC.  It went well, but after the upgrade finished, it fired up the setup wizard and when it got to the step where it tries to initiate a connection to Microsoft, it just ran and ran and ran and wasn’t going anywhere.

So a quick check showed that the Update Services service was stopped, even though it was marked as Automatic (but no auto-restart).  Once I started the service again, the wizard continued on just fine and everything is working fine.  This led me to the following solution:  Wrap the upgrade inside a script to handle it all.

Dim objShell, objWmiService, colItems, objItem, r

Set objShell = CreateObject("Wscript.Shell")
' refer to the release notes for options DO NOT accept these blindly!
r = objShell.Run(1, "cmd /c WSUSSetup.exe /g /q DEFAULT_WEBSITE=1", True)
Wscript.Echo "Upgrade has been initiated..."
' check if the WSUSService service is running, force a start if not
query = "SELECT * FROM Win32_Service WHERE Name='WSUSService'"
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colItems = objWMIService.ExecQuery(query,,48)
For Each objItem in colItems
If objItem.State <> "Running" Then
r = objShell.Run(1, "cmd /c sc start WSUSService", True)
End If

This is just ONE way to do this of course.  There are many others.  I know that I could have used another WMI method invocation on the service to request the start action.  But I’ve found some issues with that which I cannot explain (at least not on Windows 7 or Windows Server 2008 machines), where the good old SC.exe command seems to do just fine.  It’s also fewer lines of code.

Post a Comment