As I wrote on Thursday, I am battling with Windows Server 2003. Now I got a list out of our change management database, which sadly ain’t that accurate. So in order to get reliable information about the target systems (in order to do some accurate planning), I ended up writing a small vbscript which simply takes the hostname on the command line (cscript //NoLogo win_sp_level.vbs 10.0.0.5) and returns a csv-like element.

We may have to tune the script a bit more for our use, but it should show the basic functions I need.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
Dim hostname, os, servicepack

hostname = WScript.Arguments.Item(0)

strComputer = hostname
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer _
   (strComputer, "rootcimv2", hostname & "chrischie", "hah-this-password-is-easy")
objSWbemServices.Security_.ImpersonationLevel = 3

Set colOperatingSystems = objSWbemServices.ExecQuery _
   ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
   os = objOperatingSystem.Caption
   servicepack = objOperatingSystem.ServicePackMajorVersion
Next

Wscript.Echo hostname & ";" & os & "; SP" & servicepack & ";"