aseitz Posted September 29, 2011 Share Posted September 29, 2011 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 More sharing options...
Turranius Posted October 20, 2011 Share Posted October 20, 2011 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 More sharing options...
Turranius Posted October 20, 2011 Share Posted October 20, 2011 (edited) 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 October 20, 2011 by Turranius Link to comment Share on other sites More sharing options...
aseitz Posted December 15, 2011 Author Share Posted December 15, 2011 Thanks for this! I'll give it a go! Link to comment Share on other sites More sharing options...
kwacky1 Posted April 24, 2013 Share Posted April 24, 2013 Does anyone else get an error on the PerformAction method? The requested action with this object has failed.: $element.PerformAction $element.PerformAction^ ERROR Link to comment Share on other sites More sharing options...
spudw2k Posted April 24, 2013 Share Posted April 24, 2013 @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. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
kwacky1 Posted April 26, 2013 Share Posted April 26, 2013 (edited) @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 April 26, 2013 by kwacky1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now