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.

image

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):
image

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:
image

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

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.

 

Posted on GARYTOWN.COM

Leave a Reply

Your email address will not be published. Required fields are marked *

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