在powershell中执行脚本时出错WSUS GetUpdate()
我执行了一个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 ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜+ NotSpecified:(:) [],MethodException + FullyQualifiedErrorId:MethodCountCouldNotFindBest
Approve-WsusUpdate:无法绑定参数'Update'。 无法将“Microsoft.UpdateServices.Internal.BaseApi.Update”类型的“Microsoft.UpdateServices.Internal.BaseApi.Update”值转换为键入“Microsoft.UpdateServices.Commands.WsusUpdate”。 在行:22个字符:32 +批准WsusUpdate更新$更新 - 行动安装 - 目标组名称'环境'+ ~~~~~~~ + CategoryInfo:InvalidArgument:(:) [Approve-WsusUpdate],ParameterBindingException + FullyQualifiedErrorId:CannotConvertArgumentNoMessage ,Microsoft.UpdateServices.Commands.ApproveWsusUpdateCommand
链接地址: http://www.djcxy.com/p/29091.html