Repairing corrupted Windows Update Database with PowerShell and SCCM

Ioan Popovici
MEM.Zone

--

When a botched software update corrupts half of your fleet windows update database this script might come in handy…

🚨🚨 IMPORTANT NOTICE🚨🚨

🦄 An updated version can be found at MEM.Zone 🦄

🚨🚨 IMPORTANT NOTICE🚨🚨

Script release history

L ast month lot of complains about slowness started pouring in and an angry mob began to assemble outside of my office. Somehow the WUDatastore got corrupted on a few thousand machines causing severe slowdowns.

In my case the application event log was full of ESENT errors (event id 623).

wuaueng.dll (2160) SUS20ClientDataStore: The version store for this
instance (0) has reached its maximum size of 16Mb. It is likely that a
long-running transaction is preventing cleanup of the version store and
causing it to build up in size. Updates will be rejected until the
long-running transaction has been completely committed or rolled back.

The solution was to remove and reinitialize the WUDatastore. Nuking the whole database seems a bit extreme but so is being hanged by an angry mob. I could not find another solution so I added a script to a baseline with automatic remediation. This workaround should take care of any future occurrences. You can also use the run script feature if time is of the essence.

Script

Script parameters

  • DetectAndRepair
    Performs detection and then performs repairs if necessary.
  • Detect
    Performs detection and returns the result.
  • Repair
    Performs repairs and flushes the specified EventLog.
  • RepairStandalone
    Performs repairs only.

Notes
Like with any other WUDatastore reinitialization the update history will be lost. The update install history however will remain untouched in Programs and Features \View installed installed updates.
Keep in mind that the Eventlog used in the detection will also be cleared if RepairStandalone is not specified.

Repair WUDataStore corruption

Using the run script feature

Using the run script feature
Configuration item Compliance Rule

Use Github for 🐛 reporting, or 🌈 and🦄 requests

🙏 Please subscribe or clap for this article, it makes a difference! 🙏

--

--