使用Powershell批准WSUS副本上的WSUS更新

我们有3个WSUS副本服务器和一个副本连接到的中央服务器。 从中央服务器,我们正在pipe理3个副本。 所有客户端只连接到副本。

我正在尝试创build一个PowerShell脚本,它应该只批准更新,这是任何服务器所需的。

我的问题是:如果我在中央服务器上查询有关“所需”计数的信息,我总是得到零补丁。 这是因为没有客户端连接到中央服务器。 如何获得这四个(或三个)服务器的总和信息?

我目前拥有的是:

# Get WSUS Server [reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null $wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer(); $updateScope = new-object Microsoft.UpdateServices.Administration.UpdateScope; $computerScope = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope; #Get all available Updates $wsusupdates = $wsus.GetUpdates($updateScope) $updateTotalCount = $wsus.GetUpdateCount($updateScope) foreach($update in $wsusupdates) { # Get the summary $summary = $update.GetSummary($computerscope); $neededCount = ($summary.InstalledPendingRebootCount + $summary.NotInstalledCount) # Only install, if any server needs the update if ($neededCount -gt 0) { $update.Approve("Install", ($wsus.GetComputerTargetGroups() | Where-Object{$_.Name -eq $aSelectedWsusGroup})) } } 

关键部分是线路

 $summary = $update.GetSummary($computerscope); 

在那里我得到的更新信息 – 包括。 之后我需要的“需要”计算。

最后问题是:如果需要更新,如何在更新摘要中包含副本服务器数据?

顺便说一句:我试图从中央WSUS服务器副本上远程运行脚本,但批准命令不允许在副本服务器上。

添加$ computerScopeIncludeDownstreamComputerTargets = $ true

 $computerScope = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope; $computerScope.IncludeDownstreamComputerTargets = $true 

假设:

  • 副本服务器启用了汇总 ,
  • 两个客户端都有足够的时间向服务器报告,并从下游服务器(DSS)上传到上游服务器(USS)。 到此为止,您应该在UI中看到需要的更新。