这个是可能的吗?
我想我们需要以某种方式调用WUAgent来运行检测,但我希望从本质上下载并安装更新,然后作为脚本的一部分重新启动。
这将是一个更大的脚本的一部分,基本上通过Powershell构建一个普通的2008R2盒子到一个DC。
发布于 2013-03-02 21:45:59
看看PowerShell的PSWindowsUpdate模块。
它位于here at the Script Center
发布于 2016-07-19 19:40:43
我建议使用这个脚本
Function WSUSUpdate {
$Criteria = "IsInstalled=0 and Type='Software'"
$Searcher = New-Object -ComObject Microsoft.Update.Searcher
try {
$SearchResult = $Searcher.Search($Criteria).Updates
if ($SearchResult.Count -eq 0) {
Write-Output "There are no applicable updates."
exit
}
else {
$Session = New-Object -ComObject Microsoft.Update.Session
$Downloader = $Session.CreateUpdateDownloader()
$Downloader.Updates = $SearchResult
$Downloader.Download()
$Installer = New-Object -ComObject Microsoft.Update.Installer
$Installer.Updates = $SearchResult
$Result = $Installer.Install()
}
}
catch {
Write-Output "There are no applicable updates."
}
}
WSUSUpdate
If ($Result.rebootRequired) { Restart-Computer }来源:https://gist.github.com/jacobludriks/9ca9ce61de251a5476f1
https://stackoverflow.com/questions/15175054
复制相似问题