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