我执行了一个Powershell脚本,但是我收到了一个错误
[datetime]$dataIni = "2017/01/01"
[datetime]$dataFim = "2017/01/20"
$serverWsus = "server1"
[void]
$wsus =[Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($serverWsus,$False,8530)
Write-Progress -Activity 'Getting updates...' -PercentComplete 0
$updatesneeded = $wsus.GetUpdate() | ? {($_.CreationDate -gt
[datetime]$dateFirst -and
$_.CreationDate -lt [datetime]$dateLast) -and
($_.Title -notmatch "Itanium" -and
$_.Title -match "Windows Server 2008 x64" -and
$_.UpdateClassificationTitle -eq "Security Updates")}
$i = 0
$total = $updatesneeded.Count
foreach ($update in $updatesneeded)
{
Write-Progress -Activity 'Approving updates...' -Status "%Complete" -
PercentComplete (($i/$total) * 100)
Approve-WsusUpdate -Update $update -Action Install -TargetGroupName 'enviroment'
$i++
}
Write-Host "Updates approved: $total" -ForegroundColor Yellow
Cannot find an overload for "GetUpdate" and the argument count: "0".
在行:11 char:1 + $ updatesneeded = $ wsus.GetUpdate()| ? {($ _。CreationDate -gt [datetime] $ dateFirs ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:NotSpecified:(:) [],MethodException + FullyQualifiedErrorId:MethodCountCouldNotFindBest
批准-WsusUpdate:无法绑定参数'更新'。无法转换" Microsoft.UpdateServices.Internal.BaseApi.Update"类型的值" Microsoft.UpdateServices.Internal.BaseApi.Update" 键入" Microsoft.UpdateServices.Commands.WsusUpdate"。 在行:22 char:32 + Approve-WsusUpdate -Update $ update -Action Install -TargetGroupName' enviroment' + ~~~~~~~ + CategoryInfo:InvalidArgument:(:) [Approve-WsusUpdate],ParameterBindingException + FullyQualifiedErrorId:CannotConvertArgumentNoMessage,Microsoft.UpdateServices.Commands.ApproveWsusUpdateCommand