<p>J’ai written a script with the intention of quickly managing the <a href="https://en.wikipedia.org/wiki/Windows_Server_Update_Services" rel="noopener nofollow ugc">WSUS</a> process, and J’ai quelques things I hard coded in, but would rather get with PowerShell. In particular, the ‘Target’ groups for Approve-WsusUpdate.</p>
<p>Currently I’m doing something like this:</p>
<pre><code class="lang-auto">#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]
</code></pre>
<p>Is there a ‘get-targets’ command which will create an array of available target groups? This way I could remove the manual declaration of <code>$TargetComputerGroups</code>.</p>
<p>De plus, J’aimerais to make the <code>$UserPrompt</code> a better set of code (again avoiding manual declarations). Je pense doing something like <code>'$i for $i in $TargetComputerGroups' write-host 'Press 1 for i'</code></p>
<p>That being said, I am VERY new to this, so Je ne sais pas the best way to do that (ideally mapping their selection to the correct group in that statement!).</p>