Skip to content

Compare Windows Patch Baselines With Python and PowerShell

Admin
November 20, 2026
5 min read
Intermediate
πŸ’» Target OS: Windows (PowerShell 7+ / Python 3.10+)

Before you begin

  • Applies to:Windows targets with a supported remoting endpoint and a report workstation running Python 3.10 or later.
  • Where to start:Open PowerShell 7 or later on the domain management workstation.
  • What you need:Have approved WinRM access and an account allowed to read the target servicing keys.
Guide tools
Guide tools
0/0 Steps (0%)

Downloads

Steps

01

Define the minimum build for each target

Save baseline.json with the FQDNs used by the collector. These builds are illustrative. Use your approved minimum and build family for each OS release.

{
"srv01.example.com": "26100.33822",
"srv02.example.com": "26100.33822"
}
02

Collect from approved hosts

Run in the directory containing the scripts. The collector uses the existing session identity and remote settings and reads the build, revision, and common servicing reboot keys. Warnings identify failed collection targets. The JSON retains a status row for each. Run small batches and record when each was collected.

Terminal window
.\Collect-WindowsPatchState.ps1 -ComputerName srv01.example.com,srv02.example.com | Set-Content -Encoding utf8 collection.json
03

Compare with the baseline

Use the same FQDNs in both files. Hostname matching ignores case and a trailing DNS dot. Duplicate names after normalization are rejected. Expect meets_build_baseline, pending_reboot, below_baseline, wrong_build_family, or a missing or failed collection status. Exit 0 means all targets meet the baseline, 1 means review is needed, and 2 means invalid or unreadable input.

Terminal window
python windows_patch_report.py baseline.json collection.json
04

Verify after the maintenance window

Verify

For a pending reboot, review update history and schedule an approved restart. For failed collection, restore access through your existing management workflow. Recollect after one correction and compare against the same baseline.

References

Comments