After some more crunching on my VBscript, I think I finally have a working script that runs through a csv-list I point it to and walk onto each system (by ip-address only sadly) and query the os and the Service Pack that is installed. The CSV may look like this:
1
2
3
| Hostname;IP;Model;Description;OS;Service-Pack;BL;Priority
epimetheus;10.0.0.2;VMware guest;File-Server
hades;10.0.0.1;VMware guest;Core-Router
|
After saving that one, and running a cscript //NoLogo win_sp_level.vbs you should find a completed list like this:
1
2
3
| Hostname;IP;Model;Description;OS;Service-Pack;BL;Priority
epimetheus;10.0.0.2;VMware guest;File-Server;Windows Server 2003 Standard x64 Edition; SP1;;
hades;10.0.0.1;VMware guest;Core-Router;Windows Server 2003 Enterprise Edition; SP0;;
|
The final script looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
| On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemOBject")
If objFSO.FileExists("Rollout_SP2.csv") = 0 Then
CleanUp()
Wscript.Quit
End If
Set CSVin = objFSO.OpenTextFile("Rollout_SP2.csv", 1)
CSVin_read = CSVin.ReadLine
Set objFile = objFSO.CreateTextFile("Rollout_SP2_result.csv")
Set objFile = nothing
Set CSVout = objFSO.OpenTextFile("Rollout_SP2_result.csv", 8)
CSVout.WriteLine("Hostname;IP;Model;Description;OS;Service-Pack;BL;Priority")
Do While CSVin.AtEndofStream <> True
Dim os, servicepack
Dim user, password
os = nothing
servicepack = nothing
user = vars(1) & "chrischie"
password = "hah-this-password-is-easy"
current_line = CSVin.ReadLine
vars = Split(current_line, ";")
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer _
(vars(1), "rootcimv2", user, password, "MS_409",, 128)
objSWbemServices.Security_.ImpersonationLevel = 3
Set colOperatingSystems = objSWbemServices.ExecQuery _
("Select * from Win32_OperatingSystem")
' The set returns an Err.Number of 91 on success
' Don't ask me why though.
If Err.Number <> 91 Then
CSVout.WriteLine(vars(0) & ";" & vars(1) & ";" & vars(2) & ";" & vars(3) & ";NA;SP?;;")
Else
For Each objOperatingSystem in colOperatingSystems
os = objOperatingSystem.Caption
servicepack = objOperatingSystem.ServicePackMajorVersion
Next
CSVout.WriteLine(vars(0) & ";" & vars(1) & ";" & vars(2) & ";" & vars(3) _
& ";" & os & "; SP" & servicepack & ";;")
End If
Loop
|
The only thing I still need to improve is the error handling (as in notify when a system is being skipped due to RPC being unavailable).