I have written a script with the intention of quickly managing the WSUS process, and I have a few things I hard coded in, but would rather get with PowerShell. In particular, the 'Target' groups for Approve-WsusUpdate.

Currently I'm doing something like this:

#Select Target Group for Update Approval:

$TargetComputerGroups = "All Computers", "Unassigned Computers", "Clients", "Servers", "Test", "View Templates"

$UserPrompt = @"

Please select a Computer Group from the below options:

1) All Computers (Selects all of the below)
2) Unassigned Computers
3) Clients
4) Servers
5) Test
6) View Templates

Enter selection

###Record user selection to varirable
$TargetComputerGroupTemp = Read-Host -Prompt $UserPrompt

###Convert their choice to the correct 0-index array value.
$TargetComputerIndex = $TargetComputerGroupTemp -1

$ComputerTarget = $TargetComputerGroups[$TargetComputerIndex]

Is there a 'get-targets' command which will create an array of available target groups? This way I could remove the manual declaration of $TargetComputerGroups.

In addition, I would like to make the $UserPrompt a better set of code (again avoiding manual declarations). I think doing something like '$i for $i in $TargetComputerGroups' write-host 'Press 1 for i'

That being said, I am VERY new to this, so I don't know the best way to do that (ideally mapping their selection to the correct group in that statement!).


You can do it with PowerShell, but you need to have the WSUS administration console installed on the machine too.

You can then do the following.


$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer(“wsus_server”,$False)


You can then get a list of target groups with


Or select a group with

$targetgroup = $wsus.GetComputerTargetGroups() | ? {$_.Name -eq "some target name"}

There is much more information in Use PowerShell to Perform Basic Administrative Tasks on WSUS, but the above information will get you information on the groups.

  • Oooph. The more I try to give in to powershell the more I get disappointed =/ I'll accept this if I don't hear anything else by the end of the day. The link looks great and thank you for your help! – Abraxas Sep 2 '15 at 17:00
  • Give in to it :) I find myself using it for a lot. Often even if there isn't a native powershell command someone has written a module for it. – Drifter104 Sep 2 '15 at 17:30
  • Yeah, I just wish the UpdateServices Module had the ability to Get-TargetGroups or something like that because it's a property on 3 other commands within it lol =/ I'm also new to this powershell stuff and that ' [void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")' is SO weird to me still. Either way, thanks! – Abraxas Sep 2 '15 at 17:32

As Drifter104 said, there isn't yet a PowerShell module available for managing WSUS, although one will be included in the next Windows Server release (https://technet.microsoft.com/en-us/library/hh826166.aspx); meanwhile, you need to import the .NET assembly for managing WSUS and use that; one of the greatest features in PowerShell is, even if it doesn't include native cmdlets for performing a given task, you have access to the full .NET enviroment from it, and you can actually do anything you would be able to do from a .NET application.

About the scripting part: once you get the names of your WSUS groups in an array, dinamically building the list shown to your users is quite easy; simply loop through the array and use an index for the selection number:

Write-Host Please select a Computer Group from the below options:

$i = 1

foreach($g in $TargetComputerGroups)
    Write-Host Press $i for $g

$sel = Read-Host -Prompt "Enter selection: "

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.