Scripts Node: Task Sequence Info & Remediation.

So this script is just a part of one that I’ve developed for using at WF.  The other one includes a lot more logic for remediation based on our WaaS Process Registry Keys that get created during the process.  So I’ve cleaned it up, and stripped out a bunch to make it more generic to work in any environment.

The Script itself is like 75% functions, then 25% running actions.

Overview of what it does:

  • Reports the Parameters you’ve specified
    • ForceTSReset = This will force resetting of the CCMExec & SMSTSMGR services & process, effectively killing off a running (hung) TS.  This will not run even if set to true if already upgraded ($CurrentBuild = $BuildNumber) Default = False
    • ScriptLogging = Do you want it to log localling and on the server? Default = True
    • ForceTriggerTS = Will kick off the PreCache or IPU TS, if both are available, IPU wins and will kick off. This will not run even if set to true if already upgraded ($CurrentBuild = $BuildNumber)  Default = False
    • DeleteExecutionHistory = It will find any Execution History for the PackageIDs you’ve specified, then delete them.  This is another potential fix to help you retry running a TS . Default = False
    • TSPCPackageID = Package ID of the PreCache TS
    • TSIPUPackageID = Package ID of your IPU TS
  • Report Make & Model
  • Report Current OS Build
  • Report CMCache Size & Fix if less than 25GB
  • Disk Size & Free Space & Run Cleanup if less than 20GB Free
  • Find Task Sequences Available to Machine
    • Based on PackageID’s you’d put in parameters
  • List Execution History of those PackageID
  • Delete Execution History of those PacakageIDs
    • Based on True or False Parameter
  • Report Status & Startup Type of CCMExec & SMSTSMGR
  • Report Provisioning Mode Status and Remediate
  • If Machine has not already upgrade to the build you specify in Parameter (ex 1803)
    • Gets Status if TS is hung
    • Gets Status if SetupHost is running
    • Will attempt to close the TS nicely
    • Get Status if TS still hung
    • Resets the CM Client & TS Services to clear out any running TS
    • Triggers the Upgrade TS
      • If you set the Parameter to Trigger TS
  • If the Services were Reset, it rechecks..
    • Waits 10 minutes for Policy to update
    • Checks if same Task Sequences are available
    • Will try to Trigger again with updated policy
      • If you set the Parameter to Trigger TS

This will log everything locally on the machine and on a server share (See previous post for more details)

Feel free to modify to fit your needs.  Hope this is useful, or at least parts.

In Action:
In the Console, 1607 Machine, it has run the PreCache TS, but not the 1803 Upgrade (as showing by the Execution History).   You can also see in this example that the CCMCache size was less than the desired 25GB, so it set it to 25GB for you.    This machine is looking pretty good, no TS is hung, and the Upgrade has never executed, so it's all set now to try to upgrade.


Here is when the “ForceTriggerTS” is set to True, yep you guessed it, it kicks off the upgrade (if its not restricted by a service window):

Here is Example of running Script on the machine after the upgrade to 1803, it now has execution history for both the PreCache & Upgrade.  I set this test with “Delete TS Execution” set to True, then rerun to show they are no longer found:

Here you can see the network file log has captured all of my testing:

Please note, I have not been able to reproduce a “Hung TS” in my lab, but I’ve tested the “Reset-TaskSequence” function on many machine and it does pull them out of a hung state, and get them to start checking back into ConfigMgr so I can then retry the upgrade.

So hopefully that helps explain most of what this script does, I also tried to comment a lot inside of the scripts.  If you have any questions, hit me up

I use this script in the Scripts Node, why?  Because even if the machine is not receiving policy, and the client seems “checked out”, the scripts node uses the fast channel, so it will run the script, where a package or application or TS would never get a chance to run.



12 thoughts on “Scripts Node: Task Sequence Info & Remediation.”

  1. Is there a reason for setting the SCCM cache to 25GB? Never seen it that large. Is this just to account for all your TS content?

    • Yes and no, we have a large payload during a TS, but we also use a peer-to-peer cache technology. If machines have the storage, why not leave items in cache. Also helps if machines ever need to uninstall.

    • Yes, if you check the box for Pre-Download Content for this task-sequence on the deployment General Tab. That will start pulling down any referenced content in the TS.

      • Hi,
        Is there anyway to force machines to re-download content for a precached TS?
        In powershell maybe.

          • The Pre-Caching feature of a Task Sequence isn't something you can trigger. You can trigger a machine policy, which would confirm you have the policy and then start downloading if anything has changed.
            If you want to be able to remediate, then you'd have to have a dedicated TS that just pre-caches, then you could run a remediation script that triggers the actual task sequence to run and pull down the files.

            My suggestion would be:
            2 Task Sequences that have IDENTICAL Content. One that is setup for precaching and makes no actual changes to the system, and one that runs your action. You can then use the precache version of the TS for remediation by having the Configuration Item's Remediation trigger the precache TS

            Code to trigger Task Sequence:

  2. We have seen large number of devices stuck in progress in deployment monitoring tab in sccm console even though task sequence successfully completed. We tried many solution to overcome this issue but can't get the status to be changed to success tab. Is there any way to force the client/sccm to update the particular Task sequence status in sccm?

    • I honestly never look there, I look at the status messages, and use the CM reports. Even after you force a DDR and HWInv, that status doesn't change?

      • Thank you for your reply.

        Unfortunately even though we force DDR and HWInv, it does not make any difference. We do see some intermediate socket connection failed error while execution of IPU Task sequence in SMSTS.log. We believe that could be causing this issue, but have not found the root cause yet.

  3. I'm trying to do something similar with win7 to win10. I can get my client working after a rollback but i can not reset the upgrade TS or get it out of installing status without wiping the client - resetting wmi - and reinstalling the client.


Leave a Comment

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