PSWindowsUpdate

repository·main·Indexed 19 days ago

https://github.com/mgajda83/pswindowsupdate

A PowerShell module for managing the Windows Update Client. It provides functionality to search, install, hide, and uninstall updates, manage service managers, view update history, and configure Windows Update settings using cmdlets such as Get-WindowsUpdate, Add-WUServiceManager, Get-WUHistory, and Set-WUSettings.

Tokens
793
Snippets
6
Records
6
Agent score
18%

What's inside PSWindowsUpdate

  1. Install the PSWindowsUpdate module

    main

    To install the PSWindowsUpdate module from the PowerShell Gallery, first ensure your machine is using TLS 1.2. Then, use Install-Module or Install-PSResource.

    Prerequisite (if TLS 1.2 is not native):

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

    Installation commands:

    Install-Module PSWindowsUpdate
    # OR
    Install-PSResource PSWindowsUpdate
    Install-Module PSWindowsUpdate
  2. Search and install Windows Updates

    main

    Use Get-WindowsUpdate or its alias Install-WindowsUpdate to find and manage available updates.

    Common Tasks:

    List available updates on the local machine:

    Get-WindowsUpdate

    Search remote machines with filters: Search for updates on a remote computer (-ComputerName) using regular expressions on the title (-Title) and including Microsoft updates (-MicrosoftUpdate).

    Get-WindowsUpdate -ComputerName MG-PC -MicrosoftUpdate -Title "Aktualizacja.*Windows 11" -Verbose

    Hide specific updates: To prevent specific updates from being installed, use the -KBArticleID and the -Hide flag.

    Get-WindowsUpdate -KBArticleID KB4034658 -Hide -Verbose
    # OR
    Hide-WindowsUpdate -KBArticleID KB4034658 -Verbose

    Schedule an installation job: You can schedule an update installation at a specific time using -ScheduleJob. Combined with -AcceptAll and -AutoReboot, this allows for unattended maintenance.

    Get-WindowsUpdate -MicrosoftUpdate -UpdateID ddb74579-7a1f-4d1f-80c8-e8647055314e -RevisionNumber 200 -ScheduleJob (Get-Date -Hour 18 -Minute 0 -Second 0) -Install -AcceptAll -AutoReboot -Verbose
  3. Configure Windows Update settings

    main

    Manage the Windows Update Client configuration using Get-WUSettings and Set-WUSettings.

    View current configuration:

    Get-WUSettings

    Set Target Release Version: Use Set-WUSettings to control Feature Updates or Windows Update for Business by specifying the product version and target release info.

    Set-WUSettings -TargetReleaseVersion -TargetReleaseVersionInfo 22H2 -ProductVersion "Windows 10"
  4. Register Windows Update Service Managers

    main

    Use Add-WUServiceManager to register different service managers for Windows Update.

    Register Microsoft Update:

    Add-WUServiceManager -MicrosoftUpdate

    Register from an offline scan file: Use the -ScanFileLocation parameter to register an Offline Sync Service from a .cab file.

    Add-WUServiceManager -ScanFileLocation C:\wsusscn2.cab
  5. View and manage Windows Update history

    main

    Use Get-WUHistory to retrieve the history of Windows Update operations.

    View all history:

    Get-WUHistory

    View history for a specific timeframe: Use the -MaxDate parameter to filter history (e.g., for the last 24 hours).

    Get-WUHistory -MaxDate (Get-Date).AddDays(-1)