Windows Updates PowerShell Script

Windows Updates PowerShell Script

There have been a lot of critical exploits over the last few months. Really the best way to deal with that is Windows Updates. Now I can hear you complaining that Windows Updates left untamed will just reboot your servers randomly or I don’t want to build WSUS or my RMM doesn’t patch well and it sucks and <insert your excuse here>.

Well I’ve created a PowerShell script that I called DK Win Updates that will help solve the issue. It uses the Windows Update Agent API to search for updates and guess what you can run this as .ps1 file, you could build a scheduled task to run it, you can toss it in your RMM and run it as a script. (if your RMM can’t do that, you should find a new RMM).

The script will search for Windows Updates as if you were clicking on the Windows Check for updates UI button. It will not download driver updates because I’m not that crazy. Do that yourself or tweak the script to make it do it (but I wouldn’t).

Once the script finds updates it will list out all the updates it found and then it will start downloading them and then it will move onto installing them.

After the updates are installed if the updates need a reboot it will reboot the system and give a 5 min warning before rebooting.

A logged in user would see this if they ignored your emails about Windows Updates

I’ve only tested this on Windows 10, Windows Server 2016, and Windows Server 2019. It might work on older versions of Windows it might not. You should really upgrade.

A few things to be aware of

I plan to add more features to it in the future like better verbose output about what its downloading and what its installing and also sending that to a log output file.

The script can be downloaded from my GitHub https://github.com/thedxt/win-updates

Exit mobile version