Coder Social home page Coder Social logo

nimbus117 / zwindowsupdate Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 3.0 15 KB

Search for, download and install windows updates on local or remote computers using PowerShell

Home Page: https://www.powershellgallery.com/packages/zWindowsUpdate

PowerShell 100.00%
powershell windows update windowsupdate powershell-module powershell-script

zwindowsupdate's Introduction

zWindowsUpdate

The idea behind the module was to have a way to manually run Windows Update on groups of servers in a controlled fashion. The module consists of 2 parts, the zWUScript.ps1 script and the *-zWU* functions. The script does the actual work of installing updates and can be used on its own without the functions. The functions use PSSessions and CimSessions to create and control scheduled tasks that run the script.

Example

Below is an example of how to update a handful of remote computers. In this case the tasks will automatically select which updates to download and install.

    $comp = 'SRV01', 'SRV02', 'SRV03', 'SRV04', 'SRV05', 'SRV06'
    
    New-zWUTask -ComputerName $comp -AutoSelect
    Start-zWUTask -ComputerName $comp

    # or using the pipeline

    New-zWUTask -ComputerName $comp -AutoSelect | Start-zWUTask

You can use the Wait-zWUTask function to show a progress bar and wait until all tasks are complete.

    New-zWUTask -ComputerName $comp -AutoSelect | Start-zWUTask | Wait-zWUtask

Then use the Get-zWULog function to review the latest log entry from each task.

    Get-zWULog -ComputerName $comp

    ComputerName Timestamp           Level   Message
    ------------ ---------           -----   -------
    SRV06        29/07/2017 04:38:40 Warning Finished - Reboot required - 24 of 24 update(s) installed
    SRV02        29/07/2017 03:20:55 Warning Finished - Reboot required - 24 of 24 update(s) installed
    SRV01        29/07/2017 03:14:16 Warning Finished - Reboot required - 24 of 24 update(s) installed
    SRV04        29/07/2017 03:20:55 Warning Finished - Reboot required - 24 of 24 update(s) installed
    SRV03        29/07/2017 03:10:19 Info    Finished - No reboot required - 1 of 1 update(s) installed
    SRV05        29/07/2017 03:10:17 Info    Finished - No reboot required - 1 of 1 update(s) installed

Rolling it all together.

    New-zWUTask -ComputerName $comp -AutoSelect | Start-zWUTask | Wait-zWUtask | Get-zWULog

    # or the shorthand way also suppressing the prompts for confirmation

    nzt $comp -con:0 -au | szt -con:0 | wzt | gzl

If a reboot is required to finish installing updates you can use the Restart-Computer Cmdlet.

    Restart-Computer -ComputerName SRV01,SRV02,SRV04,SRV06 -Force -Wait

Alternatively you can set a task to reboot automatically after updates are installed.

    New-zWUTask -ComputerName $comp -Confirm:$false -AutoSelect -Reboot | 
    Start-zWUTask -Confirm:$false

More Examples

    # Use the Get-ADComputer and Out-GridView Cmdlets to select which computers to update
    $comp = (Get-ADComputer -Filter "name -like 'SRV*'").Name | Out-GridView -PassThru

    # The -Service parameter can be useful for bypassing WSUS
    New-zWUTask -ComputerName $comp -Service WindowsUpdate

    # Filter by update type and exclude a given KB number
    New-zWUTask $comp -UpdateType CriticalUpdates,SecurityUpdates,Definitions -ExcludeKB KB2267602

    # Use the -SearchOnly parameter to see what updates are needed
    New-zWUTask -ComputerName $comp -Confirm:$false -SearchOnly

    # Use the -Full parameter to view the full log for a task
    Get-zWULog 10.10.10.10 -Credential $cred -Full

    ComputerName Timestamp           Level Message
    ------------ ---------           ----- -------
    10.10.10.10  02/03/2018 16:13:45 Info  ## zWindowsUpdate ##
    10.10.10.10  02/03/2018 16:13:45 Info  Parameter - AutoSelect = True
    10.10.10.10  02/03/2018 16:13:45 Info  Parameter - SearchOnly = True
    10.10.10.10  02/03/2018 16:13:45 Info  Parameter - Service = WindowsUpdate
    10.10.10.10  02/03/2018 16:13:45 Info  Starting windows update session
    10.10.10.10  02/03/2018 16:13:45 Info  Searching for updates
    10.10.10.10  02/03/2018 16:13:53 Info  Found 3 update(s) (0B-1.2GB)
    10.10.10.10  02/03/2018 16:13:53 Info  Windows Malicious Software Removal Tool x64 - February 2018 (KB890830) (0B-38.4MB)
    10.10.10.10  02/03/2018 16:13:53 Info  2018-02 Cumulative Update for Windows Server 2016 for x64-based Systems (KB4074590) (0B-1.1GB)
    10.10.10.10  02/03/2018 16:13:53 Info  Update for Windows Defender antimalware platform - KB4052623 (Version 4.12.17007.18022) (0B-3.1MB)
    10.10.10.10  02/03/2018 16:13:53 Info  Finished - Search only - 3 update(s) found

    # When viewing full logs from multiple computers the filtering capabilities of Out-GridView can be helpful
    Get-zWULog $comp -Full | Out-GridView

    # Use Get-zWULog and Out-Gridview to select which computers to restart
    $Restart = (gzl $comp | ogv -pas).ComputerName
    Restart-Computer -ComputerName $Restart -Force -Wait

    # Remove the task and script files
    Remove-zWUTask -ComputerName $comp

Installation

The module is available from the PowerShell Gallery or you can download and extract the zip file from here.

    Install-Module -Name zWindowsUpdate -Scope CurrentUser

    # or

    Start-BitsTransfer https://github.com/nimbus117/zWindowsUpdate/archive/master.zip
    Expand-Archive .\master.zip .
    Import-Module .\zWindowsUpdate-master\zWindowsUpdate.psd1

Run help about_zWindowsUpdate and help <Function-Name> -Full to see more examples and a description of the available parameters.

zwindowsupdate's People

Contributors

nimbus117 avatar

Stargazers

 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.