VBScript to Run SCCM Software Updates Scan

Posted on Updated on

A challenge with installing software updates during a task sequence is that it may occur where not all updates are applied on the first pass.   The workaround is run software updates, run a VB Script or PowerShell script to force another scan, then run a software updates task again.  Others have posted their scripts on this before, so it’s nothing new.  However, I failed trying to quickly locate those scripts.  So I’m just posting my own of what I use….

' AUTHOR: Nick Moseley , https://t3chn1ck.wordpress.com
' DATE  : 7/30/2010

' COMMENT: Initiates an SCCM client scan
' Script from http://msdn.microsoft.com/en-us/library/cc144313.aspx
' Updated 7/15/11 to include a sleep before exiting script
' Set the required variables. 
actionNameToRun = "Updates Source Scan Cycle"
' Create a CPAppletMgr instance.
Dim oCPAppletMgr
Set oCPAppletMgr = CreateObject("CPApplet.CPAppletMgr")
' Get the available ClientActions object.
Dim oClientActions
Set oClientActions = oCPAppletMgr.GetClientActions()
' Loop through the available client actions. Run the matching client action when it is found.
Dim oClientAction
For Each oClientAction In oClientActions
 If oClientAction.Name = actionNameToRun Then
 End If
' Wait for 3 minutes for scan completion before exiting script


7 thoughts on “VBScript to Run SCCM Software Updates Scan

    Martin Pot said:
    March 12, 2012 at 10:32 am

    I have had bad experience with making a call to CPApplet.CPAppletMgr on 64bit systems as the SCCM client is 32 bits. However when I executed a WMI call (as in the powershell example), which is independent of the system, I didn’t have any problems. VBS code for this is:

    Schid = “{00000000-0000-0000-0000-000000000113}”
    sMachine = “.”
    Set WMItarget = GetObject(“winmgmts://” & sMachine)
    Set WMICCM=GetObject(“Winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\” & sMachine & “\root\ccm”)
    set SMSCli = WMICCM.Get(“SMS_Client”)
    set oParams = SMSCli.Methods_(“TriggerSchedule”).inParameters.SpawnInstance_()
    oParams.sScheduleID = Schid
    set res = WMICCM.ExecMethod(“SMS_Client”, “TriggerSchedule”, oParams)

    More SCCM WMI Schedule ID’s are:

    ScheduleID Name
    {00000000-0000-0000-0000-000000000001} Hardware inventory
    {00000000-0000-0000-0000-000000000002} Software inventory
    {00000000-0000-0000-0000-000000000003} Data Discovery Report
    {00000000-0000-0000-0000-000000000010} File Collection
    {00000000-0000-0000-0000-000000000021} Machine Policy Retrieval & Evaluation (machine policy assignment request)
    {00000000-0000-0000-0000-000000000022} Machine policy evaluation
    {00000000-0000-0000-0000-000000000023} Refresh default MP
    {00000000-0000-0000-0000-000000000024} Refresh location services (Ad site, or subnet)
    {00000000-0000-0000-0000-000000000025} Request timeout value for tasks
    {00000000-0000-0000-0000-000000000026} Request user assignments
    {00000000-0000-0000-0000-000000000027} Evaluate user policies
    {00000000-0000-0000-0000-000000000031} Software metering usage reporting
    {00000000-0000-0000-0000-000000000032} Request software update source (Windows Installer Source List)
    {00000000-0000-0000-0000-000000000037} Refresh proxy manamgement point
    {00000000-0000-0000-0000-000000000040} Cleanup policy
    {00000000-0000-0000-0000-000000000042} Validate assignments
    {00000000-0000-0000-0000-000000000051} Certificate maintenance
    {00000000-0000-0000-0000-000000000061} DP: Peer DP status report
    {00000000-0000-0000-0000-000000000062} DP: Peer DP pending status check
    {00000000-0000-0000-0000-000000000108} Evaluate software update assignment (Software Updates Deployment)
    {00000000-0000-0000-0000-000000000111} State message upload
    {00000000-0000-0000-0000-000000000112} Clean state message cache
    {00000000-0000-0000-0000-000000000113} Sofware update scan
    {00000000-0000-0000-0000-000000000114} Software update deployment re-eval
    {00000000-0000-0000-0000-000000000120} Out-Of-Band management scheduled event

    Remote execution without powershell is also a possibility (this off course doesn’t work with a Task Sequence):
    WMIC /node:[Computername] /namespace:\\root\ccm path sms_client CALL TriggerSchedule “{00000000-0000-0000-0000-000000000113}”

    Q&A from the Power of Task Sequences « t3chn1ck said:
    April 2, 2012 at 10:34 pm

    […] A: You have a good eye ;-)  That script is available on my blog at https://t3chn1ck.wordpress.com/2012/01/26/vbscript-to-run-sccm-software-updates-scan/ […]

    Russell Johnson said:
    April 3, 2012 at 10:12 am

    I put sendschedule.exe from the SCCM ToolKit in a package and then call it with the {scheduleID} on the TS command line: “sendschedule.exe {00000000-0000-0000-0000-000000000113}”

      Nicolas Moseley responded:
      April 3, 2012 at 10:15 am

      Interesting approach, thanks for sharing it. I’ll have to try that out some time!

    mcitpsa said:
    October 17, 2012 at 4:44 am

    Here’s another way to use the “sendsched” from the powershell without any vbs script :)
    It’s helpfull if you plan to use powershell scripts in the future for troubleshooting sccm clients.

      N. Moseley responded:
      October 17, 2012 at 6:52 am

      Thanks for contributing!

    mcitpsa said:
    October 28, 2013 at 9:03 am

    Changed my Blogstrukture…. here’s the correct Link to my example with the Sendshed and Powershell :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s