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

Read more

Scripts Node, Add Local & Network Logging to Script

This is basically two posts in one, add logging to your scripts in the script node, and Get Service Windows Info, check if you have any deployments being squashed by too restrictive Services Windows, and remove the service windows if you want to.  Why add logging… several reasons, to know what the script did, to have a “paper trail”, and helps with troubleshooting.  I’ve added logging to my scripts for accountability as well.  I have it log to a network share because I’m not local admin on the boxes I’m running the scripts on, so having a central share to collect the scripts is very important to me when I’m troubleshooting issues.

The reason I wrote this script was because we've run into machines that would never run the Upgrade because they would return with a status message "deployment will never run, too restrictive of service window".  We do not check the box on our deployments to run outside of a Service Window, as we want to respect what the Business Unit have said are their approved times to service machines.  However there are times when the windows are just too small for the time we've specified in our TS, or someone created a local service window manually, using a tool like Client Center, to accomplish a one-off task and never cleaned it up.  So I created a script that would read the execmgr.log file, search for a restrictive window issue, then delete them (based on parameters).  You can search for Local Service Windows or Server Side (Collection) Service Window and delete those, or choose Delete all service windows.  Common Sense Warning:  Use with Caution, and Test please.  This script is deleting Service Windows which restrict installs / reboots from happening all willy nilly.  If you start removing those restrictions… well.. you get it.

image Read more