Not every shop runs WSUS, but every server still needs patching. If your evidence that a box is up to date is “someone remoted in last month and clicked Check for updates”, you do not have patch management — you have a habit.
The gap I see most often in smaller regulated estates is not that patching is neglected. It is that it is unrecorded and uncontrolled: updates install when the machine feels like it, reboots land in the middle of the working day, and nobody can produce a per-host list of what was applied and when. The fix does not require a WSUS server or a paid platform. It requires the PSWindowsUpdate module, a scheduled task defined in code, and the discipline to log the result. This walks through a setup that scans, installs the right classes of update, confines the reboot to a maintenance window, and leaves a report behind.
Installing the module and pointing it at Microsoft Update
PSWindowsUpdate is a community module by Michal Gajda, published on the PowerShell Gallery. It is a wrapper over the Windows Update Agent COM API, so it works on a standalone server with no WSUS in sight. Install it for all users so the scheduled task running as SYSTEM can find it:
Free · 4 minutes
Would you survive contact with a determined attacker — or an auditor?
Fourteen questions on access, patching, detection, and recovery — the basics that prevent most real incidents, and the ones most often assumed rather than verified. Banded finding on screen, full sheet by email.
# Run in an elevated PowerShell 7.4 session
Set-ExecutionPolicy -Scope LocalMachine RemoteSigned -Force
Install-PackageProvider -Name NuGet -Force
Install-Module -Name PSWindowsUpdate -Scope AllUsers -Force
# One-off: register the Microsoft Update service so you get more
# than just OS patches (Office, SQL Server, etc.)
Import-Module PSWindowsUpdate
Add-WUServiceManager -MicrosoftUpdate -Confirm:$false
# Confirm what's on offer without installing anything
Get-WindowsUpdate -MicrosoftUpdate
A note on PowerShell 7. The module loads in 7.x through the Windows PowerShell compatibility layer, which is fine interactively. For an unattended scheduled task on Windows Server 2022 I still tend to invoke the job under powershell.exe (5.1), because the Windows Update COM calls are most reliably exercised there and it removes one moving part from the thing you least want to debug at 02:00. Everything below runs identically either way.
Installing the right updates, and excluding the wrong ones
The default behaviour of Install-WindowsUpdate is greedy. On a server you rarely want driver updates arriving unattended, and you almost never want preview or optional-quality updates. The -NotCategory, -NotTitle and -NotKBArticleID filters let you carve those out. Here is the core install line, deliberately conservative:
Install-WindowsUpdate -MicrosoftUpdate -AcceptAll `
-NotCategory 'Drivers' `
-NotTitle 'Preview' `
-IgnoreReboot `
-Verbose
Three flags carry the weight. -AcceptAll suppresses the per-update confirmation prompt so the run is genuinely unattended. -NotCategory 'Drivers' keeps hardware drivers out; -NotTitle 'Preview' drops the monthly C/D-week preview cumulative updates that Microsoft ships ahead of Patch Tuesday. Crucially, -IgnoreReboot installs everything but does not restart the machine — because you want the reboot to happen on your schedule, not the module’s. If a specific KB is causing you trouble, add -NotKBArticleID 'KB5060842' to hold it back without blocking everything else.
A script that patches, reports, and reboots in a window
Now assemble it. This script installs the approved classes, writes a timestamped per-host report, and only triggers a restart if one is pending and the current time falls inside an agreed maintenance window. Save it as C:\Scripts\Invoke-Patching.ps1.
[CmdletBinding()]
param(
[int]$RebootStartHour = 2, # maintenance window opens 02:00
[int]$RebootEndHour = 5 # and closes 05:00
)
Import-Module PSWindowsUpdate
$stamp = Get-Date -Format 'yyyy-MM-dd'
$logDir = 'C:\Scripts\Logs'
if (-not (Test-Path $logDir)) { New-Item -ItemType Directory -Path $logDir | Out-Null }
$report = Join-Path $logDir "$stamp-$env:COMPUTERNAME-patch.log"
# Install approved updates; hold the reboot back for now
Install-WindowsUpdate -MicrosoftUpdate -AcceptAll `
-NotCategory 'Drivers' -NotTitle 'Preview' `
-IgnoreReboot -Verbose |
Format-Table Result, KB, Size, Title -AutoSize |
Out-File -FilePath $report -Encoding utf8 -Append
# Decide whether to reboot, and only inside the window
$hour = (Get-Date).Hour
if ((Get-WURebootStatus -Silent) -and
($hour -ge $RebootStartHour) -and ($hour -lt $RebootEndHour)) {
Add-Content $report "Reboot required and within window - restarting at $(Get-Date)"
Restart-Computer -Force
} else {
Add-Content $report "No reboot performed at $(Get-Date). Pending: $(Get-WURebootStatus -Silent)"
}
Get-WURebootStatus -Silent returns a plain boolean, which is what makes the window check readable. Because the scheduled task itself fires inside the maintenance window, the hour test is really a belt-and-braces guard against a long-running install spilling past 05:00 — in that case the machine skips the reboot and simply flags it as pending in the report for someone to pick up.
Scheduling it as code, not clicks
Register the task from PowerShell so the definition lives in source control rather than in a GUI nobody can diff. I have argued the general case for defining scheduled tasks as PowerShell code instead of clicking through Task Scheduler — patching is the exact workload that makes the point.
$action = New-ScheduledTaskAction -Execute 'powershell.exe' `
-Argument '-NoProfile -ExecutionPolicy Bypass -File C:\Scripts\Invoke-Patching.ps1'
# Every Sunday at 02:00 - inside the maintenance window
$trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Sunday -At 2am
$principal = New-ScheduledTaskPrincipal -UserId 'SYSTEM' `
-LogonType ServiceAccount -RunLevel Highest
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable `
-ExecutionTimeLimit (New-TimeSpan -Hours 3)
Register-ScheduledTask -TaskName 'Monthly-Patching' `
-Action $action -Trigger $trigger -Principal $principal `
-Settings $settings -Force
Patching you can evidence, not assume
The point of all this is the last mile: proof. After a run, verify from a second source rather than trusting the installer’s own word. Get-HotFix reads the installed-updates list straight from the servicing store, and Get-WUHistory gives you the module’s own record with results:
# What's actually installed, most recent first
Get-HotFix | Sort-Object InstalledOn -Descending | Select-Object -First 10
# The module's history, with success/failure per update
Get-WUHistory | Select-Object Date, Result, KB, Title -First 20
Run the same pattern against remote hosts with the -ComputerName parameter (WinRM enabled, or use Invoke-WUJob to push the job as a one-off scheduled task under SYSTEM on each target), and you have a per-host patch report you can hand to an auditor. This sits directly alongside a CIS-aligned hardening baseline you can verify and the first hardening pass on a fresh Server 2022 build: a hardened box that then drifts unpatched is not hardened for long.
A supervisor does not ask whether you believe your servers are patched. They ask you to show which patch landed on which host, and when. Automate it, log it, and that question stops being a bad afternoon.
Free interactive tool
Website compliance checklist
What your site has to do, based on what it actually does
Answer as much or as little as you like — the list builds as you go. Nothing is stored against your name and no email is required.
Everything that applies
Ordered by what to do first: legal requirements you can close quickly, then larger pieces of work, then what is expected rather than required. Not exhaustive, and not a legal audit.
Dated PDF, yours to keep or circulate.
Most technology problems are not technology problems. They are control problems.
The systems exist. The investment has been made. The question is whether leadership can understand, direct, evidence, and sustain what those systems produce. Find out where control exists — and where it only appears to.