Forum Discussion

dmarquesgn's avatar
dmarquesgn
Iron Contributor
May 29, 2022

Run Windows Updates with Powershell Remotely

Hi, I'm kind of new to Powershell, and trying to automate some stuff. I found one nice Powershell module named PSWindowsUpdate to manage Windows Updates. I need to create some automated updating fo...
  • dmarquesgn's avatar
    dmarquesgn
    May 31, 2022
    Thanks for the tip.
    I would like to avoid WSUS, as it also has some challenges, and at the same time I would learn more on Powershell.

    Meanwhile I was already able to use a command to update remotely, now I need to deal with errors and logging, which is not so good at the moment.

    Set-Item WSMan:\localhost\Client\TrustedHosts –Value * -Force
    $Script = {Get-WindowsUpdate -KBArticleID KB4535680 -AcceptAll -Install -Verbose | Out-File C:\Temp\PSWindowsUpdate.log}
    Invoke-WUjob -ComputerName <computername> -Script $Script -Confirm:$false -RunNow

Resources