January 24 2012

Force SCCM optional advertisement to run

I needed a script that was going to run tigger optional SCCM advertisement to run. Why? Because I was using Opalis to trigger multiple advertisements across multiple systems in a certain sequence. I had tried the SCCM Client Center Integration Pack for Opalis, however the Run Advertisements function didn’t seem to work. So my Opalis workbook simply calls the below script and passes it the SCCM package ID and program name (ie force_run.vbs PACKAGEID PROGRAMNAME). See below for VBScript:

' Purpose: Forces optional advertised programs that meet packageID and program name criteria to run
' Note: There must already be a SCCM advertisement in place
' Use: force_run.vbs PACKAGEID PROGRAMNAME (case sensitive)
' Author: blog.danovich.com.au

' Get input parameters
Dim Arg, packageID, programName
Set Arg = WScript.Arguments
packageID = Arg(0)
programName = Arg(1)
Set uiResource = CreateObject("UIResource.UIResourceMgr")
Set programList = uiResource.GetAvailableApplications

' Set flags for error tracking
flag_package = "notavailable"
flag_program = "notavailable"

' Match each given packageID and program name against applications available to the machine
For each p in programList
If p.PackageID = packageID then
flag_package = "available"
If p.Name = programName Then
uiResource.ExecuteProgram p.ID, p.PackageID,True
flag_program = "available"
Exit For
End If
End If

' Give feedback if the given packageID or program name do not match available applications
If flag_package = "notavailable" then
wscript.echo packageID & " does not match any Package ID in available applications"
End If
If flag_program = "notavailable" and flag_package = "available" then
wscript.echo programName & " does not match any program name in available applications or is not associated with Package ID " & packageID
End If

' Give feedback if everything matches
If flag_program = "available" and flag_package = "available" then
wscript.echo "Program name " & programName & " from package ID " & packageID & " ran successfully."
End If

' Clean up
Set uiResource = Nothing
Set Arg = Nothing


I use a maximum of one Google Ad per post to help offset some of my blog hosting costs.


Tags: , , , , , , , ,

Posted January 24, 2012 by danovich in category "Opalis / Orchestrator", "Scripting", "SMS / SCCM


  1. By ss on

    i am trying to automate task sequence through Opalis,do you have any pointers for me ?or any workbooks ( samples )


Leave a Reply