Run Scripts: Trigger Task Sequence

Update: New “Lite” Versions – On GitHub which checks execution history.

Goal: Trigger Task Sequence remotely via Run Script. Allows you to trigger on one computer or several. *The Policy for the Task Sequence most already be on this machine.

Choose a Collection / Computer and Run Script

Type the Package ID for the Task Sequence you want to trigger on the machines:

You can Hover over for more info:

This machine doesn’t have that TS Package ID available to Trigger – Results return quickly
This machine Triggered, and has successful confirmation of the TS starting in the execmgr.log
This one triggered, but the TS could not start because of a MW
This machine Triggered, but failed to register that it started the TS in execmgr

The Return information is LIMITED to a couple scenarios I check for.
Process:

  • Check for Task Sequence on Machine with Package ID
  • Trigger Task Sequence
  • Wait 2 Minutes
  • Check ExecMgr Log for:
    • Successful launch of TS with Package ID
    • Waiting for MW
  • If neither of those options are found in the log, it Reports “Failure”**
    • This can be a false positive… Example… If you have the TS set to download content before starting, it could still be downloading the required content after you triggered it… so eventually the TS might still kick off after the content has downloaded.

For more details you’ll need to dig through the execmgr and other logs.

Now… the script:

https://gist.github.com/gwblok/7365f34dae8ede63b6b588299ef1aa61

Let me know if you use it and how it goes… GARYTOWN.COM
PS… special shout out to Jeff Scripter for the Function I use to parse the execmgr log.

10 thoughts on “Run Scripts: Trigger Task Sequence”

  1. I loaded your script into VSCode and it detected “99 problems in this file”. When attempting to run it, it generates so many error that is states “Not all errors were reported. Correct the reported errors and try again.”

    Reply
  2. Thanks for this, Gary. One thing I’m curious about… what’s the significance of CAS29CDE-CAS04823-6F6BCC28 in the xml string? Before your script changes it, it matches $TSScheduleMessageID. I thought it was a mistake, so I tried tweaking your script to leave it as the actual message ID, but the TS always fails to trigger. So, I admitted that you obviously knew what you were doing and put it back the way you had it, which then worked fine. But now I have to know… where did you get that value and what’s so special about it?

    Reply
    • You know what, I didn’t even realize that was there. Technically there is nothing special about it.
      If I had time, I’d look into it, probably can remove that line completely, but I’d have to dig in.

      I used Client Center to get the basics to the code that triggers the TS, then added params and other code to make it into a Run Script and provide feedback.

      Client Center: https://github.com/rzander/sccmclictr

      Reply
  3. Dude, 90% of this code is not necessary and makes it more difficult for others to modify or debug. Can you trim it down to the essentials?

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.