6

これは可能ですか?

検出を実行するには、なんらかの方法でWUAgentを呼び出す必要があると思いますが、基本的には更新プログラムをダウンロードしてインストールし、スクリプトの一部として再起動したいと思います。

これは、基本的にPowershellを介してDCまでのバニラ2008R2ボックスを構築するためのより大きなスクリプトの一部になります。

4

2 に答える 2

9

PowerShell用のPSWindowsUpdateモジュールを見てください。

ここはスクリプトセンターにあります

于 2013-03-02T13:45:59.130 に答える
3

このスクリプトを使用することをお勧めします

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

于 2016-07-19T11:40:42.857 に答える