Jump to content

AutoIT SCCM Action Trigger Script Needed


aseitz
 Share

Recommended Posts

I am trying to find / write some code to do this:

http://eskonr.com/2011/01/script-to-trigger-machine-policy-or-hardware-inventory-action-agent-on-sccm-clients/

Some searches on this forum lead me to:

Unfortunately that guys script is not functional.

I am simply trying to execute the Discovery trigger:

;Discovery Data Collection Cycle

;CPApplet Name: Discovery Data Collection Cycle

;ScheduledMessageID: {00000000-0000-0000-0000-00000003}

Anyone out there already done this? Or know someone who has?

Link to comment
Share on other sites

  • 3 weeks later...

Bit old now perhaps, but I managed to trigger SCCM 2007 actions using autoit..

$oCPAppletMgr = ObjCreate ("CPApplet.CPAppletMgr")
If @ERROR <> "0" Then
    msgbox(16,"Function failed.", "SCCM client not installed? Reported error: " & @ERROR)
    Exit
EndIf
$oClientActions = $oCPAppletMgr.GetClientActions
If @ERROR <> "0" Then
    msgbox(16,"Function failed.", "Can not interact with SCCM Client. Reinsatll the SCCM client. Reported error: " & @ERROR)
    Exit
EndIf

$elements=""
FOR $element in $oClientActions
  $elements=$elements & @LF & $element.name
  If $element.name = "Request & Evaluate Machine Policy" Then
    ;Msgbox(0,"", $element.name)
    ;$element.PerformAction
  EndIf
NEXT

msgbox(64,"Elements in list", $elements)

This one will do nothing except for giving you a list of actions you can trigger.

If you look at the remmed out part, its checking if $element.name is "Request & Evaluate Machine Policy".

If you want to run that, simply remove the ; infront of ;$element.PerformAction

Otherwise, just change "Request & Evaluate Machine Policy" to whatever action you want from the $elements list..

/Turranius

Link to comment
Share on other sites

Here it is again, a bit nicer perhaps =)

SCCMAction("Request & Evaluate Machine Policy")
 
Func SCCMAction($CalledFunction)
  If $CalledFunction = "" Then
    msgbox(16, "Internal Error", "No function to call passed to SCCMAction")
    Return
  EndIf
 
  $oCPAppletMgr = ObjCreate ("CPApplet.CPAppletMgr")
  If @ERROR <> "0" Then
    msgbox(16,"Function failed.", "SCCM client not installed? Reported error: " & @ERROR)
    Return
  EndIf
 
  $oClientActions = $oCPAppletMgr.GetClientActions
  If @ERROR <> "0" Then
    msgbox(16,"Function failed.", "Can not interact with SCCM Client. Reinsatll the SCCM client. Reported error: " & @ERROR)
    Return
  EndIf
 
  Local $ActionCalled
  FOR $element in $oClientActions
    If $element.name = $CalledFunction Then
      Msgbox(64,"The following action was triggered successfully", $element.name)
      $element.PerformAction
      $ActionCalled = "1"
      Return
    EndIf
  NEXT
 
  If $ActionCalled <> "1" Then
    MsgBox(16, "Internal Error", "Function called (" & $CalledFunction & ") was not accepted by SCCM client.")
    Return
  EndIf
EndFunc

If you want to list all the actions you can call, below the line

FOR $element in $oClientActions

add:

msgbox(0,"Action found", $element.name)

Edited by Turranius
Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...

@kwacky1 Please take note of the time and date of the last posting. This thread hasn't been active since Dec 15 2011.

It is ok to have questions but resurrection of an old thread typically doesn't get much response.

You'd be better off asking for help by starting a new thread and referencing this example.

Link to comment
Share on other sites

@spudw2k, it's ok, wasn't urgent, just thought it was better here as this is the thread that turned up in google.

Anyway, I added the error handler as per the COM reference in AutoIt Help and get the following error returned "Application was launched but it didn't register a class factory"

Even better, because the error handler allows the script to continue, the method actually gets run.

UPDATE: Turns out I only get the error when running from within Scite, compiled script works every time.

Edited by kwacky1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...