Using Chef to Run Windows update

Community,

Is it just me or is anyone else having issues using Chef to run windows update on remote nodes? I tend to use the PowerShell block to send a PowerShell command to run the windows update. When chef runs it immediately returns that the command has ran successfully yet when you log into the remote node and status the updates nothing changes (nothing happens). I am not trying to make this super hard by developing some elaborate scripts. I think something like this should be rather simple, but for some reason it isn't. Please share what your doing that is successful?

Thank you,

hunt,

Can you post the block you used?

-Tim

powershell_script 'Run Windows Update' do
    code <<-EOH
      Start-Process -FilePath "PowerShell" -ArgumentList "Install-WindowsUpdate -AcceptAll -AutoReboot" -Verb RunAs
    EOH
  end

Sorry for the delay... Let me know.

Thank you,

Hey @tas50 just following up with you. Let me know.

This person solved this in 2015 a certain way: https://cloudrobots.net/2015/09/17/apply-windows-updates-via-a-chef-recipe/

1 Like

And the PSWindowsUpdate module is not included with Powershell by default, which is where the Install-WindowsUpdate module comes from. I assume you're pre-installing that before you call your script?

This has more info: https://4sysops.com/archives/install-windows-updates-remotely-with-the-powershell

There are lots of articles on the web about this.

Jeff,

Yes I user chef and several cookbooks is used for the pre-install and was hoping that it would work, but I have run into issues where it just doesn't work.

What I would recommend is dropping a script and setting up a scheduled task via Chef. IMO don't treat Chef like a scheduling service, it's config management. Updates can take time to install, sometimes requires reboots, etc.
You can checkout how we did this at FB. https://youtu.be/azP3I5tm3ho