Install Windows Updates Remotely

email me

If you have ever had to install Windows updates, as in patching servers, you know you have to log into servers and allow updates to install, suppressing reboots along the way. To remotely install updates, try some of these methods.

PowerShell

Invoke-Command -ComputerName ServerName {wusa.exe C:\Updates\Windows6.1-KB894199-x64.msu /quiet /norestart}

 
 

VBScript

Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

set filetxt = objFSO.OpenTextFile("C:\Servers.txt",1)
strPSExec = "C:\PSExec.exe"
rbcopy = "c:\Windows\System32\Robocopy.exe"

strPSExec = objFSO.GetFile(strPSExec).ShortPath
rbcopy = objFSO.GetFile(rbcopy).ShortPath

Do Until filetxt.AtEndOfStream
strServerName = filetxt.Readline
strServerName = trim(strServerName)

'Copy updates
strCmd = "%comspec% /c " & rbcopy & " C:\Updates" & " \\" & strServerName & "\c$\Updates"
WScript.echo strCmd
objShell.Run strCmd, 1, True

'Run updates
strCmd = "cmd /C " & strPSExec & " \\" & strServerName & " ""C:\Updates\"" /quiet"
WScript.echo strcmd
objShell.Run strCmd, 1, True

Loop

 
 

Command in Script

psexec \\ServerName -c -s -u Domain\Administrator -p P@$$W0rd \\ShareName\PathToWUInstall\WUInstall.exe /install

 
 

Notes

If you have issues with PSExec, try PAExec.

wusa.exe “\\ServerName\winupdates\windows6.1-kb894199-x64.msu”

https://blogs.technet.microsoft.com/heyscriptingguy/2011/08/13/use-powershell-to-audit-and-install-windows-patches/

https://gallery.technet.microsoft.com/scriptcenter/Force-Install-Updates-on-ef821f9a