Windows
View all Worklets
WindowsWindows

Windows - Maintenance Tasks - Create WSUS Computer Target Groups

Enforce WSUS computer target groups on Windows Server endpoints to back client-side update ring tagging

Worklet Details

What the WSUS target group enforcer does

This Automox Worklet™ enforces the existence of WSUS computer target groups on a Windows Server running the Windows Server Update Services role. The Worklet imports the UpdateServices PowerShell module that ships with the WSUS role, connects to the server via Get-WsusServer -Name $serverName -PortNumber $port, and iterates through a configured $groupNames array. Any group that is missing from GetComputerTargetGroups() is created under the All Computers root with CreateComputerTargetGroup().

The Worklet exposes three parameters at the top of evaluation.ps1 and remediation.ps1: serverName (the WSUS host name), port (defaulted to 8530, the standard WSUS HTTP port), and groupNames (a PowerShell array such as @('Laptops', 'Servers', 'Workstations', 'Pilot', 'Production')). The evaluation phase exits 2 on the first missing group, which flags the endpoint non-compliant in Automox and queues remediation. The remediation phase re-checks each name and only creates the groups that are still absent, so the operation is idempotent across repeated policy runs.

Group creation on the server is only half of the WSUS target-group story. The other half lives on each client endpoint, where the registry keys at HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate control which group the client reports itself into. The TargetGroup value names the group, and TargetGroupEnabled must be set to 1 for client-side targeting to take effect. After the registry is in place, the client picks up the assignment on its next detection cycle, which you can force immediately with wuauclt /detectnow /resetauthorization. This Worklet runs on the WSUS server and guarantees the named groups exist before the clients try to land in them.

Why enforce WSUS target groups on every WSUS server

WSUS computer target groups are the unit of approval inside Windows Server Update Services. Approve a Patch Tuesday rollup against the Pilot group on Monday, watch it for forty-eight hours, then approve the same rollup against Production on Wednesday. That entire staged rollout collapses the moment a group is missing on the server. Clients tagged with TargetGroup = Pilot that find no matching group on the WSUS server fall back to All Computers, which silently breaks the ring and pushes every update to every host at once. The same failure mode hits CIS Microsoft Windows Server Benchmark control 18.10.92 (Configure Automatic Updates) and the staged-deployment guidance in NIST 800-53 SI-2 patch management. Without enforced groups, the controls have no surface to land on.

WSUS group definitions disappear in predictable ways. A backup admin removes a group during a WSUS cleanup, a rebuild script forgets to recreate the group set, or a junior engineer renames Pilot to Pilots and breaks every client tagged with the original spelling. This Worklet runs on the WSUS server itself, validates the configured group set against the IUpdateServer.GetComputerTargetGroups COM enumeration on every cycle, and recreates any missing group before the next maintenance window opens with broken approvals.

How WSUS target group enforcement works

  1. Evaluation phase: The Worklet calls Get-WsusServer -Name $serverName -PortNumber $port to bind to the WSUS instance, then enumerates the live group list with $wsusServer.GetComputerTargetGroups(). It walks the configured $groupNames array and uses Where-Object { $_.Name -eq $groupName } to match each name against the live set. The first missing group triggers Write-Output 'GROUP NOT FOUND: <name>' and exit 2, which flags the endpoint non-compliant. When every configured group is already present, the script writes 'All specified WSUS Computer Groups exist on <serverName>' and exits 0.

  2. Remediation phase: The remediation script rebinds to the WSUS server and walks the same array. For each missing group, it calls $wsusServer.CreateComputerTargetGroup($groupName) inside a try block and logs 'CREATED GROUP: <name>' on success. Any exception is caught and emitted as Write-Error 'FAILED TO CREATE: <name> <message>' followed by exit 2, so the failure reason surfaces in Automox activity logs. Existing groups are skipped, which makes the remediation safe to re-run after partial failures or after a WSUS console operator adds one of the groups by hand.

WSUS target group enforcement requirements

  • Windows Server with the WSUS role installed; the role ships the UpdateServices PowerShell module the Worklet depends on

  • Network reachability from the Automox agent context to the WSUS server on the configured port (default 8530 for HTTP, 8531 for HTTPS; set port to match your wsusutil postinstall configuration)

  • Local administrator privileges on the WSUS host, or membership in the WSUS Administrators group, so CreateComputerTargetGroup() succeeds

  • Endpoint targeting in the Automox policy scoped to the WSUS server only; running this Worklet against a non-WSUS host will fail at Get-WsusServer with an UpdateServices module load error

  • Configured parameters in evaluation.ps1 and remediation.ps1: $serverName (the WSUS host), $port (8530 or 8531), and $groupNames as a PowerShell array such as @('Laptops', 'Servers', 'Workstations', 'Pilot', 'Production')

  • Client-side Group Policy or registry that sets HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\TargetGroup to the matching group name and HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\TargetGroupEnabled to 1 on each endpoint that should land in a managed group

Expected WSUS state after target group enforcement

After successful remediation, every name in $groupNames appears under Computers > All Computers in the WSUS console (Update Services snap-in). The activity log records a 'CREATED GROUP: <name>' line for each newly created group, or 'All specified WSUS Computer Groups exist on <serverName>' when the server was already compliant. Subsequent policy evaluations exit 0 without invoking remediation, because GetComputerTargetGroups() now matches every configured name on the first pass.

Validate from PowerShell on the WSUS server with (Get-WsusServer).GetComputerTargetGroups() | Select-Object Name, Id and confirm each expected name is in the output. Validate from a tagged client endpoint by setting the TargetGroup registry value, running wuauclt /detectnow /resetauthorization (or UsoClient StartScan on Windows 10 and later), and watching the client appear under the assigned group inside the WSUS console after the next detection cycle. For audit evidence, export the group list to CSV with the same Select-Object pipeline and store the file with the Automox policy run identifier. The groups persist across WSUS service restarts and survive wsusutil reset operations; they are only removed when an administrator deletes them through the console or PowerShell, at which point the next evaluation flags the server non-compliant and the Worklet restores the missing group on the next remediation run.

View in app
evalutation image
remediation image

Consider Worklets your easy button

What's a Worklet?

A Worklet is an automation script, written in Bash or PowerShell, designed for seamless execution on endpoints – at scale – within the Automox platform. Worklets deploy named-CVE mitigations within hours of disclosure, perform configuration, remediation, and install or remove applications and settings across Windows, macOS, and Linux.

do more with worklets