这一直在困扰我一段时间。 我们的服务器设置为只下载Windows更新,以便在双月补丁窗口之一中安装它们。 在这段时间里,我已经看到了高低的一种方法来在服务器上远程触发安装,所以我不必login到一百或更多的服务器,并点击“立即安装更新”气球。
任何人都知道一种方法来远程触发更新安装?
我终于明白了。 有一个(几乎)文件的Windows更新API,你可以用来触发这些types的东西。 我使用了这里find的脚本的一个修改后的forms,这个脚本尽可能接近文档。
我修改它如下,取出下载件 – 因为我控制下载与GPO和WSUS,以及所有的提示。 然后,我插入了一些代码来重新启动框,如果需要的更新。
Set updateSession = CreateObject("Microsoft.Update.Session") Set updateSearcher = updateSession.CreateupdateSearcher() WScript.Echo "Searching for updates..." & vbCRLF Set searchResult = updateSearcher.Search("IsInstalled=0 and Type='Software'") WScript.Echo "List of applicable items on the machine:" For I = 0 To searchResult.Updates.Count-1 Set update = searchResult.Updates.Item(I) WScript.Echo I + 1 & "> " & update.Title Next If searchResult.Updates.Count = 0 Then WScript.Echo "There are no applicable updates." WScript.Quit End If Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl") WScript.Echo vbCRLF & _ "Creating collection of downloaded updates to install:" For I = 0 To searchResult.Updates.Count-1 set update = searchResult.Updates.Item(I) If update.IsDownloaded = true Then WScript.Echo I + 1 & "> adding: " & update.Title updatesToInstall.Add(update) End If Next 'WScript.Echo vbCRLF & "Would you like to install updates now? (Y/N)" 'strInput = WScript.StdIn.Readline 'WScript.Echo 'If (strInput = "N" or strInput = "n") Then ' WScript.Quit 'ElseIf (strInput = "Y" or strInput = "y") Then WScript.Echo "Installing updates..." Set installer = updateSession.CreateUpdateInstaller() installer.Updates = updatesToInstall Set installationResult = installer.Install() 'Output results of install WScript.Echo "Installation Result: " & _ installationResult.ResultCode If (installationResult.RebootRequired = True) Then Set RebootShell = WScript.CreateObject("Wscript.Shell") RebootShell.Run "shutdown.exe -r -t 0" End If WScript.Echo "Reboot Required: " & _ installationResult.RebootRequired & vbCRLF WScript.Echo "Listing of updates installed " & _ "and individual installation results:" For I = 0 to updatesToInstall.Count - 1 WScript.Echo I + 1 & "> " & _ updatesToInstall.Item(i).Title & _ ": " & installationResult.GetUpdateResult(i).ResultCode Next 'End If
下一步就是把它与psExec粘在一起 – 它不喜欢远程运行VBScript。 我将下面的batch file放在一起,将脚本本地复制到服务器,然后使用以System用户身份运行的psExec启动安装:
for /f %%i in (%1) do copy installUpdates.vbs \\%%i\c$ psexec @%1 -s cscript C:\installUpdates.vbs
现在你所需要的只是把批处理脚本传给一个文本文件,里面有你的计算机的名字 – 每行一个,你就可以走了。 没有更多的login到每个服务器启动Windows更新安装!
有一个令人讨厌的问题是,这是一个非常串行的执行,所以如果你有很多的更新可能需要一段时间。 我找不到一个很好的解决方法,除了分解你的机器列表和运行batch file的多个副本。 不是世界末日。
一点更新。 我发现有一些安装需要用适当的安装权限进行交互式login。 基本上如果wsus说,它没有安装你必须打开盒子。 虽然这是从login到每个框中的一个很好的步骤。
使用GPO将它们设置为在您的窗口中的某个时间段自动安装,然后在双月窗口滚动前几个小时才批准更新。
你仍然可以批准他们的testing台机器,看看他们是否会导致世界内爆,这确保他们都在窗口之前下载,并批准他们的所有服务器之前,你离开办公室在你更新窗口的一天(我假设这是在一个不喜欢的早晨不愉快的时刻),他们都应该在你第二天来的时候完成。
如果您想要非顺序运行,只需将-d添加到PSEXEC命令行。 然后,它将以非交互方式运行installupdates.vbs。
还有WuInstall 。 免费版似乎并不比您已经放在一起的WUA API脚本更好,但专业版可以select自动接受eula,我想这是导致大部分交互式更新的必要条件。