PowerShell – How to Start Windows Updates Remotely on Windows 2016 Servers

powershellwindowswindows-update

I have 10 domain joined Windows 2016 servers. I need to run Windows updates on them, I don't want to logon on to each of them, and then manually start Windows Updates.

I found that you can do it with;

Install-Module PSWindowsUpdate

But I don't know how exactly.

**** Update; thanks to duenni, this was my final solution. Install PSWindowsUpdate modules and then;

Set-Item WSMan:\localhost\Client\TrustedHosts –Value * -Force

$Script = {import-module PSWindowsUpdate; Get-WindowsUpdate -AcceptAll -Install -Verbose -AutoReboot | Out-File C:\PSWindowsUpdate.log}

Invoke-WUjob -ComputerName s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s20 -Script $Script -Confirm:$false -RunNow

Best Answer

As per Release Notes (click on "Package Details") the command Invoke-WUInstall has been replaced by Invoke-WUJob in Version 2.0.0.

Try

$Script = {import-module PSWindowsUpdate; Get-WindowsUpdate -AcceptAll -Install | Out-File C:\PSWindowsUpdate.log}

Invoke-WUjob -ComputerName $computer -Script $Script -Confirm:$false -RunNow