これは可能ですか?
検出を実行するには、なんらかの方法でWUAgentを呼び出す必要があると思いますが、基本的には更新プログラムをダウンロードしてインストールし、スクリプトの一部として再起動したいと思います。
これは、基本的にPowershellを介してDCまでのバニラ2008R2ボックスを構築するためのより大きなスクリプトの一部になります。
これは可能ですか?
検出を実行するには、なんらかの方法でWUAgentを呼び出す必要があると思いますが、基本的には更新プログラムをダウンロードしてインストールし、スクリプトの一部として再起動したいと思います。
これは、基本的にPowershellを介してDCまでのバニラ2008R2ボックスを構築するためのより大きなスクリプトの一部になります。
PowerShell用のPSWindowsUpdateモジュールを見てください。
ここはスクリプトセンターにあります
このスクリプトを使用することをお勧めします
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