Windows-Server-2003
在 Windows Server 2003 上執行 Windows 更新的腳本
是否有任何批處理腳本或命令行命令可以在多個遠端伺服器上自動執行 Windows 更新(可能通過 psexec)?不喜歡使用 VB 腳本,但如果有可用的腳本,那也沒關係。謝謝。
取決於你想怎麼做。如果您想要一個更批處理樣式的 psexec 方法,您需要查看我以前見過的共享軟體 CLI 實用程序。老實說,我自己從來沒有測試過,wuinstall。我從 Windows 類型的 IT 雜誌上看到一些文章,所以我懷疑你會是第一個。有免費軟體和專業版,但我不能說許可限制是什麼。
如果你能克服腳本,我知道這個 Winboxen sysadmin lucifist 寫了一個 PowerShell 腳本來做你正在尋找的東西。
###################################################################################################################################### # Windows Update through Powershell (No Forms) v1.0 ###################################################################################################################################### clear-host Write-host "Starting Update Process..." -foregroundcolor blue Write-host "" $UpdateSession = New-Object -com Microsoft.Update.Session $UpdateSearcher = $UpdateSession.CreateupdateSearcher() $SearchResult = $UpdateSearcher.Search("IsAssigned=1 and IsHidden=0 and IsInstalled=0") $UpdateLowNumber = 0 $UpdateHighNumber = 1 $NumberofUpdates = $searchResult.Updates.Count while ($UpdateHighNumber -le $NumberofUpdates) { $UpdatesToDownload = New-Object -com Microsoft.Update.UpdateColl $Update = $searchResult.Updates.Item($UpdateLowNumber) if ($Update.EulaAccepted -eq 0) {$Update.AcceptEula()} [void]$UpdatesToDownload.Add($Update) $Downloader = $UpdateSession.CreateUpdateDownloader() $Downloader.Updates = $UpdatesToDownload [void]$Downloader.Download() $UpdatesToInstall = New-Object -com Microsoft.Update.UpdateColl [void]$UpdatesToInstall.Add($Update) $Title = $update.Title $KBArticleIDs = $update.KBArticleIDs $SecurityBulletinIDs = $update.SecurityBulletinIDs $MsrcSeverity = $update.MsrcSeverity $LastDeploymentChangeTime = $update.LastDeploymentChangeTime $MoreInfoUrls = $update.MoreInfoUrls Write-host "Installing Update $UpdateHighNumber of $NumberofUpdates" Write-host "Title: $Title" if ($KBArticleIDs -ne "") {Write-host "KBID: $KBArticleIDs"} if ($SecurityBulletinIDs -ne "") {write-host "Security Bulletin: $SecurityBulletinIDs"} if ($MsrcSeverity -eq "Critical") {Write-host "Rating: $MsrcSeverity" -foregroundcolor red} else {Write-host "Rating: $MsrcSeverity"} if ($LastDeploymentChangeTime -ne "") {Write-host "Dated: $LastDeploymentChangeTime"} if ($MoreInfoUrls -ne "") {Write-host "$MoreInfoUrls"} $Installer = $UpdateSession.CreateUpdateInstaller() $Installer.Updates = $UpdatesToInstall $InstallationResult = $Installer.Install() Write-host "--------------------------------------------" if ($InstallationResult.ResultCode -eq "2") {Write-host " Installation Succeeded" -foregroundcolor green} else {Write-host " INSTALLATION FAILED, check event log for details" -foregroundcolor red} if ($InstallationResult.RebootRequired -eq "False") {Write-host " Reboot not required" -foregroundcolor green} else {Write-host " REBOOT REQUIRED" -foregroundcolor red} Write-host "--------------------------------------------" Write-host "" Write-host "" $Title = "" $KBArticleIDs = "" $SecurityBulletinIDs = "" $MsrcSeverity = "" $LastDeploymentChangeTime = "" $MoreInfoUrls = "" $UpdateLowNumber = $UpdateLowNumber + 1 $UpdateHighNumber = $UpdateHighNumber + 1 if ($ProgressValue -lt $NumberofUpdates) {$ProgressValue = $ProgressValue + 1} } $ComputerStatus = New-Object -com Microsoft.Update.SystemInfo if ($ComputerStatus.RebootRequired -eq 1) {cmd /c $env:WinDir\System32\Shutdown.exe -r -f -t 10 -c "Patching Complete."}
如果你注意這個腳本,你會看到你正在打開 COM 對像等。因此,您要麼需要烘焙自己的二進製文件或其他人的非 MSFT 程式碼(如 Wuinstall),要麼在 VBScript 中執行相同數量的腳本。你說的是Win23k Server,所以我不確定你是否安裝了PS。如果沒有,有TechNet 文件可以治愈您的病痛。
底線,Google是你的朋友。在此處發布之前請記住這一點。:-)