我编写了一个脚本,旨在快速管理
WSUS进程,我有一些我硬编码的东西,但宁愿使用PowerShell.特别是,Approve-WsusUpdate的“目标”组.
目前我正在做这样的事情:
#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]
是否有’get-targets’命令可以创建一系列可用的目标组?这样我就可以删除$TargetComputerGroups的手动声明.
另外,我想让$UserPrompt成为更好的代码集(再次避免手动声明).我觉得做’$i for $i for $TargetComputerGroups’写主机’按1给我’
话虽如此,我对此非常陌生,所以我不知道最好的方法(理想情况下将他们的选择映射到该语句中的正确组!).
您可以使用PowerShell执行此操作,但您还需要在计算机上安装WSUS管理控制台.
原文链接:https://www.f2er.com/windows/369946.html然后,您可以执行以下操作.
[void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") $wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer(“wsus_server”,$False) $wsus
然后,您可以获得目标组列表
$wsus.GetComputerTargetGroups()
或者选择一个组
$targetgroup = $wsus.GetComputerTargetGroups() | ? {$_.Name -eq "some target name"}
在Use PowerShell to Perform Basic Administrative Tasks on WSUS中有更多信息,但上述信息将为您提供有关组的信息.