VBScript SCCM Advertisements targeted to machine

was looking at machine to see what advertisements /packages are targeted to sccm client though you can get this information directly from SCCM reports if you have access else wrote a simple script which gives you what packages with program name,Command line used ,ADV ID,Package ID information.

ON ERROR RESUME NEXT
Set fso=CreateObject("scripting.filesystemobject")
'create text file with list of computers what you need
Set objinputfile=fso.OpenTextFile("computers.txt",1,True)
'pipe the results into output.txt file
Set objoutputfile=fso.OpenTextFile("Output.txt",2,True)
'Read the input file until end of line
Do While objinputfile.AtEndOfLine <> True
strcomputer=objinputfile.ReadLine
objoutputfile.WriteLine(strcomputer)
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\ccm\Policy\Machine")
Set Colitems = objWMIService.ExecQuery("SELECT * FROM CCM_SoftwareDistribution")
For Each objItem in colItems
objoutputfile.WriteLine("-----------------------------------")
objoutputfile.WriteLine("ADV_AdvertisementID: " & objItem.ADV_AdvertisementID)
objoutputfile.WriteLine("PKG_Name: " & objItem.PKG_Name)
objoutputfile.WriteLine("PKG_PackageID: " & objItem.PKG_PackageID)
next
Loop
msgbox("DONE")

Routine Note: Please change the quotes from the script as blog changes them to Fancy quotes.

2 Responses to "VBScript SCCM Advertisements targeted to machine"

  1. Hi,

    I am looking for vb script to create collection in SCCM2012, I am able to do it in Root folder but this needs to be placed in a particular folder under collections..

    Will you be able to help me?

    Thanks in Advance.

    Reply

Leave a Reply