First of all, i'm sorry for my english. I'm new in vbs scripting and wmi queries and I need your help.
My goal is to get the Add/Remove Programs list of a specific computer. I saw many scripts which query the Uninstall registry key on the target computer but I want to do it even if the computer is offline. That's why i'm querying the SCCM Server.
My query seems to be good because when i put it in Report Builder, it returns a good result.
Here is the query :
Select sys.Name0,adv.DisplayName0 FROM v_R_System sys , v_Add_Remove_Programs adv where sys.ResourceID=adv.ResourceID and sys.Name0 like '%XXXXXXXX%'
My problem is to get the result of the query using vbscript. I'm getting an error on the line of the "For Each"
Here is my script :
'Central SCCM Site Server name
strComputer = "SCCM_SERVER"
'Central SCCM Site Code
strSiteCode = "DC1"
'Set up the connection String
Set objWMIService = GetObject("winmgmts://" & strComputer & "\root\sms\site_" & strSiteCode)
'Get the info with a query
Set colGroups = objWMIService.ExecQuery("Select sys.Name0,adv.DisplayName0 FROM v_R_System sys , v_Add_Remove_Programs adv where sys.ResourceID=adv.ResourceID and sys.Name0 like 'XXXXXXXXXXX'")
'output the info
For Each objGroup in colGroups
Wscript.echo objGroup.DisplayName0 & " - "
Next
Can you please provide me some help ?
Update : it seems that i'm not using the right language for the query. I'm using SQL instead of WQL.
I don't know how to translate my query into WQL. Can you help please ?