Skip to content

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

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

fix: correct service flags so -WSUS actually respects WSUS#146
kbaker827 wants to merge 1 commit into
pdqcom:masterfrom
kbaker827:fix/109-wsus-service-flag

Conversation

@kbaker827
Copy link
Copy Markdown

Summary

  • Fixes the -WSUS parameter having no effect: the scanner was returning non-approved updates even when -WSUS was specified
  • Swaps the service flags: -WSUS now calls Get-WindowsUpdate with no service flag (so the WU Agent routes through the WSUS server configured by Group Policy), and the default (no -WSUS) now uses -MicrosoftUpdate to query Microsoft's full catalog

Root cause

The original code called Get-WindowsUpdate -WindowsUpdate when -WSUS was specified. In PSWindowsUpdate, -WindowsUpdate explicitly requests service ID 9482F4B4-E343-43B6-B170-9A65BC822C77 (the online Windows Update service), which bypasses WSUS filtering entirely and returns all Microsoft-hosted updates regardless of approval status.

The correct approach for WSUS is to call Get-WindowsUpdate with no service flag. The Windows Update Agent then uses whatever service is configured by Group Policy — which is the WSUS server when the machine is WSUS-managed.

Change

  If ($WSUS) {
-     $GWU = Get-WindowsUpdate -WindowsUpdate
+     # No service flag: WU Agent uses the GPO-configured service (WSUS)
+     $GWU = Get-WindowsUpdate
  }
  Else {
-     $GWU = Get-WindowsUpdate
+     # -MicrosoftUpdate queries Microsoft's catalog directly, bypassing WSUS
+     $GWU = Get-WindowsUpdate -MicrosoftUpdate
  }

Test plan

  • Run scanner with -WSUS on a machine pointing to a WSUS server — confirm only WSUS-approved updates are returned
  • Run scanner without -WSUS — confirm all available updates are returned (including those not in WSUS)
  • Run on a non-WSUS machine — confirm default behavior is unchanged

Closes #109

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
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