Skip to content

fix: correct service flags so -WSUS actually respects WSUS - #146

Open
kbaker827 wants to merge 2 commits into
pdqcom:masterfrom
kbaker827:fix/109-wsus-service-flag
Open

kbaker827 wants to merge 2 commits into
pdqcom:masterfrom
kbaker827:fix/109-wsus-service-flag

Conversation

@kbaker827

@kbaker827 kbaker827 commented May 20, 2026 •

Copy link
Copy Markdown

Summary

Root cause

The script called Get-WindowsUpdate -WindowsUpdate when -WSUS was specified. -WindowsUpdate selects Microsoft's online Windows Update service, so results ignored WSUS approvals.

Change

  If ($WSUS) {
-     $GWU = Get-WindowsUpdate -WindowsUpdate
+     $GWU = Get-WindowsUpdate -ServiceID '3da21691-e39d-4da6-8a4b-b43877bcb1b7'
  }

The README now says the target must be configured to use a WSUS server, and that without -WSUS the scanner uses whichever update service the target is configured to use.

Testing

Tested on Windows PowerShell 5.1 and PowerShell 7 with Get-WindowsUpdate stubbed, confirming which arguments each path passes. That doesn't exercise a real WSUS server. The service ID comes from the reporter's comment on #109, where they confirmed it worked in their environment.

  • Run with -WSUS on a machine pointing to a WSUS server and confirm only approved updates are returned
  • Run without -WSUS and confirm the results match the previous behavior
  • Run with -WSUS on a machine not using WSUS and check how the failure appears in the scan results

Closes #109

kbaker827 added 2 commits May 20, 2026 08:59
Previously the -WSUS switch passed -WindowsUpdate to Get-WindowsUpdate,
which forces the online Windows Update service ID (9482F4B4...) and
bypasses WSUS filtering entirely, returning all Microsoft-hosted updates
regardless of what WSUS has approved.

Fix: when -WSUS is specified, call Get-WindowsUpdate with no service flag
so the Windows Update Agent routes through the WSUS server configured by
Group Policy. When -WSUS is not specified, use -MicrosoftUpdate to query
Microsoft's catalog directly and return every available update.

Closes pdqcom#109
-WSUS now passes the WSUS service ID, which is the fix the reporter
confirmed in pdqcom#109.

Scans without -WSUS go back to no service flag. -MicrosoftUpdate made
WSUS-managed computers bypass WSUS for anyone not using the parameter,
which pdqcom#109 did not ask for.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get Available Windows Updates scanner not pulling from WSUS

1 participant