none
Initiate SCCM/ConfigMgr Client Actions via script

    Question

  • Hi, 

    I am trying to get a script working to run the ConfigMgr Client Actions remotely rather than opening it up and clicking on 'Run Now'.

    I found the below script (called "triggers") which is initiated via a batch file which runs "C:\Windows\SysWOW64\cscript.exe triggers.vbs to avoid getting the error "CPApplet.CPAppletMgr"

    The problem I have is after I run the script directly on the client device the command windows just sits there saying the below, why is this?:

    Action: Request & Evaluate Machine Policy

    Action: Request & Evaluate User Policy

    Also, How can I check that it's working, which logs do I check?

    Here's the VB Script I'm using:

    'Set Variables For Actions 
    actionNameToRun = "Updates Source Scan Cycle" 
    actionNameToRun1 = "Software Updates Assignments Evaluation Cycle" 
    'Create and use the control panel applet for client actions 
    Dim controlPanelAppletManager 
    Set controlPanelAppletManager = CreateObject("CPApplet.CPAppletMgr") 
    Dim clientActions 
    Set clientActions = controlPanelAppletManager.GetClientActions() 
    Dim clientAction 
    'Find which actions are available 
    For Each clientAction In clientActions 
    'List available client actions, output using the Name property (below). 
            wscript.echo "Action: " & clientAction.Name 
    'Run statements per results 
            If clientAction.Name = actionNameToRun Then 
                    clientAction.PerformAction 
                     
            End If 
             
            If clientAction.Name = actionNameToRun1 Then 
                    clientAction.PerformAction 
                     
            End If 
    Next 
    WScript.Sleep(180000) 
    wscript.echo "Executed: " & actionNameToRun 
    WScript.Echo "Executed: " & actionNameToRun1

    • Moved by Torsten [MVP]MVP Wednesday, August 21, 2013 4:36 PM moved to SDK subforum
    Wednesday, August 21, 2013 4:31 PM

Answers

  • WScript.Sleep(180000) 
    wscript.echo "Executed: " & actionNameToRun 
    WScript.Echo "Executed: " & actionNameToRun1


    The script is sleeping for 180000ms = 180s = 3min, so that could explain the runtime of ~5min.
    I am not sure if there will be anything recorded in PolicyAgent.log, because the script triggers "Updates Source Scan Cycle" and "Software Updates Assignments Evaluation Cycle". ScanAgent.log and WUAHandler should show activities though.

    Torsten Meringer | http://www.mssccmfaq.de

    Friday, August 23, 2013 9:15 AM

All replies

  • Hi,

    You can have a look in the policyagent.log file that a a new policy is downloaded.

    Regards,
    Jörgen


    -- My System Center blog ccmexec.com -- Twitter @ccmexec

    Wednesday, August 21, 2013 4:49 PM
  • Well the script actually completes after about five minutes and says:

    Executed: Updates Source Scan Cycle
    Executed: Software Updates Assignments Evaluation Cycle

    But I've checked the PolicyAgent.log and that's not showing anything. Any ideas on why it wouldn't be working? Is the script right?
    Friday, August 23, 2013 8:53 AM
  • WScript.Sleep(180000) 
    wscript.echo "Executed: " & actionNameToRun 
    WScript.Echo "Executed: " & actionNameToRun1


    The script is sleeping for 180000ms = 180s = 3min, so that could explain the runtime of ~5min.
    I am not sure if there will be anything recorded in PolicyAgent.log, because the script triggers "Updates Source Scan Cycle" and "Software Updates Assignments Evaluation Cycle". ScanAgent.log and WUAHandler should show activities though.

    Torsten Meringer | http://www.mssccmfaq.de

    Friday, August 23, 2013 9:15 AM
  • That's great, yes ther4e's action in those logs. 

    I want to change the script to run the Hardware and Software Inventory Cycles. Which logs can I monitor to check this works? Because there's nothing happening in the PolicyAgent.log


    Friday, August 23, 2013 11:11 AM
  • Hardware-/Software inventory will be recorded in InventoryAgent.log.

    Torsten Meringer | http://www.mssccmfaq.de

    Friday, August 23, 2013 11:31 AM
  • Yep, I meant the InventoryAGent, sorry. Nothing in there.

    Is "Hardware Inventory Cycle" the correct name and text to use?

    Friday, August 23, 2013 12:28 PM
  • Hi,

    Why do you want to use VbSCript? it´s much easier with PowerShell.

    Best,

    Kaido Järvemets

    Friday, August 23, 2013 12:31 PM
    Moderator

  • For Each clientAction In clientActions 
    'List available client actions, output using the Name property (below). 
            wscript.echo "Action: " & clientAction.Name 


    Your script is already listing all available actions and their names ... just see which one is HINV/SINV.

    Torsten Meringer | http://www.mssccmfaq.de

    Friday, August 23, 2013 1:17 PM
  • Cheers. Yes, I missed that - too many other things going on. So that script works with "Hardware Inventory Collection Cycle".

    Thanks for your help.

    Also this WMIC Command works:

    Trigger Hardware Inventory:
    WMIC /namespace:\\root\ccm path sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000001}" /NOINTERACTIVE

    http://myitforum.com/cs2/blogs/rzander/archive/2008/08/11/sms-sccm-commandline.aspx

    @Kaido I've not used powershell before so that's why. Can you provide an example of a powershell script to look over please?
    Friday, August 23, 2013 1:39 PM
  • Just visit Kaido's website www.cm12sdk.net. There are numerous examples.

    Torsten Meringer | http://www.mssccmfaq.de

    Friday, August 23, 2013 1:52 PM
  • thanks
    Friday, August 23, 2013 3:42 PM
  • Hi,

    how to trigger User policy using PowerShell ?


    Sonam Rastogi

    Monday, December 16, 2013 7:04 AM
  • Hi,

    It is in the examples on Kaido's site as well. http://cm12sdk.net/?p=1503

    Regards,
    Jörgen


    -- My System Center blog ccmexec.com -- Twitter @ccmexec

    Monday, December 16, 2013 7:35 AM