Quantcast
Channel: configmgr – All about Microsoft Endpoint Manager
Viewing all articles
Browse latest Browse all 265

VBScript SCCM Advertisements targeted to machine

$
0
0

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.


Viewing all articles
Browse latest Browse all 265

Trending Articles