Who needs Client-Side Targeting?

Oct 23, 2015 at 7:33 PM
Edited Oct 23, 2015 at 7:41 PM
This script gives me the ability to use the "RequestedTargetGroupName" from Client-Side targeting, but still have the power to exempt servers from patching by changing their group membership.

# Add computers to groups based on Requested Group Name attribute.
#
# ------  Connect to WSUS Server DB -------
Import-module poshwsus
Connect-poshwsusserver -wsusserver localhost -port 8530
#
$Clients = Get-PoshWSUSClient
#
foreach ($Client in $Clients) { 
   #
   # Remove the server from any Existing Groups except "All Computers" and "Unassigned Computers"
   #
   $PreexistingGroups = Get-PoshWSUSClientGroupMembership -computer $client.FullDomainName
   ForEach ($PreexistingGroup in $PreexistingGroups){
      if ($PreexistingGroup.Name -ne "All Computers" -and $PreexistingGroup.Name -ne "Unassigned Computers")`
      {
         Remove-PoshWSUSClientFromGroup -group $PreexistingGroup.Name -computer $client.FullDomainName
      }
   }
   #
   # Add computer to the Requested Group
   #
   Add-poshWSUSClientToGroup -Group $Client.RequestedTargetGroupName
}