How it works...

In step 1, you create the $WSUSServer object and use the CreateComputerTargetGroup method to define a new computer target group on your WSUS server:

In step 2, you use Get-WsusComputer to retrieve the WsusComputer object for the DC1 server and pipe this object to the Add-WsusComputer method, which adds it to the new WSUS computer target group:

In step 3, you use the GetComputerTargetGroups method of the $WSUSServer object, filtered with Where-Object, to retrieve the new 'Domain Controllers' computer target group, and store it in the variable $DCGroup:

In step 4, you use Get-WsusComputer and inspect the ComputerTargetGroupIDs property, looking for a match to the $DCGroup.Id property from the previous step to show that the DC1 computer is a member of this ComputerTargetGroup: