Git Product home page Git Product logo

simeononsecurity / chocoautomatewindowsupdates Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 3.0 11 KB

Automate Windows Updates with Chocolatey and PSWindowsUpdates

Home Page: https://simeononsecurity.com/github/automating-windows-updates-with-chocolatey-pswindowsupdate-and-startup-scripts/

License: Apache License 2.0

PowerShell 100.00%
chocolatey shutdown shutdown-script reboot startup windows windowsupdate powershell automated

chocoautomatewindowsupdates's Introduction

Automating Windows Updates with Chocolatey, PSWindowsUpdate, and Startup Scripts

     In today's modern workplace environment, system administrators constantly are battling for time. Rolling out the latest Windows updates can be extremely time consuming taking up to a week given enough systems. Along with some assistance from Chocolatey, PSWindowsUpdates, and Startup Scripts, Systems Administrators can roll out update with as little as a single reboot of each machine.

The script we will be working with today titled "chocoautomatewindowsupdates.ps1":

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco feature enable -n=allowGlobalConfirmation
choco feature enable -n useFipsCompliantChecksums
choco upgrade all
choco install pswindowsupdate
Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d -Confirm:$false
Install-WindowsUpdate -MicrosoftUpdate -AcceptAll 
Get-WuInstall -AcceptAll -IgnoreReboot

From Chocolatey, the script below installs the Chocolatey package manager:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Folowed by a couple prefered Chocolatey configuration changes;

choco feature enable -n=allowGlobalConfirmation
choco feature enable -n useFipsCompliantChecksums
choco upgrade all

Lastly we will install and run PSWindowsUpdates to install all of the available windows updates.

choco install pswindowsupdate
Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d -Confirm:$false
Install-WindowsUpdate -MicrosoftUpdate -AcceptAll 
Get-WuInstall -AcceptAll -IgnoreReboot

     Now that we have our script set up. Now we need to set it up as a startup/shutdown script. We have chosen to set it up as a shutdown script to avoid having to reboot twice. We will be following the tutorial from Microsoft to do this.

In the windows gui perform the following steps:

1.) Open the Local Group Policy Editor by hitting "Win + R" and typing "gpedit.msc" followed by "Ctrl + Shift + Enter"

2.) Navigate to Computer Configuration\Windows Settings\Scripts (Startup/Shutdown).

3.) In the results pane, double-click Shutdown.

4.) Select the powershell tab

5.) In the Shutdown Properties dialog box, click Add.

6.) In the Script Name box, type the path to the script, or click Browse to search "chocoautomatewindowsupdates.ps1" in the Netlogon shared folder on the domain controller.

7.) Reboot

8.) Profit?

Now in the future, all an administrator has to do is reboot the computer to perform windows updates.

The same steps can be performed in GPO to acomplish the same thing on multiple Windows machines at the same time.

chocoautomatewindowsupdates's People

Contributors

simeononsecurity avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.