1

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 ?

  • Eww, vbs. Use PowerShell instead, it sucks much less. – HopelessN00b Jul 8 '14 at 21:23
1

You are trying to use a SQL query to get results from CM07/CM12. You need to use WQL to query CM07/CM12. Translate your query to WQL and it should work or rewrite your VBS to query SQL directly.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.