What It Does
The script records the state of the update services, Windows Installer and Update Orchestrator and stops any that are running. It renames C:\Windows\SoftwareDistribution and catroot2 with a date stamp; it renames rather than deletes, so the copy it just made can be put back by hand.
It then starts the update, BITS and cryptographic services, checks that all three run, and restores Windows Installer and Update Orchestrator to their prior running or stopped state. It cancels BITS transfer jobs for all users and requests a scan when UsoClient is available.
With ClearOldBackups, on by default, it deletes the renamed copies from earlier runs and keeps the newest backup for each cache folder. The update history in Settings starts empty and rebuilds on the next scan. Installed updates are not touched, and it does not re-register DLLs, reset Winsock or change service permissions.
Before You Run It
- Do not run it while an update is installing. Wait for it to finish, or restart first.
- Tell the client the update history in Settings will look empty for a while. Nothing was uninstalled.
- If the same machine needs this every month, look for the cause: disk space, a proxy, or a broken update policy.
Type and Risk
- Type: Action. It makes its change, checks the change worked and says what changed. It exits 0, or 2 when it could not do the job.
- Risk: Low. Set DryRun=true, or run it with -WhatIf, to list every change without making any.
- What it changes: Stops and starts the update services; renames SoftwareDistribution and catroot2; cancels BITS jobs; deletes older .old-* copies.
- Restart: It never restarts the machine.
- Typical run: 1 to 3 minutes.
- Example answer: "Reset the update stack: SoftwareDistribution and catroot2 renamed; 3 services running; scan requested"
- Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.
Inputs
Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.
- ClearOldBackups: true to delete .old-* copies from earlier runs, keeping the newest one. Default true.
Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.
License
Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.