Home / Solution / PSWindowsUpdate: Managing Windows Updates from PowerShell

PSWindowsUpdate: Managing Windows Updates from PowerShell

To handle Windows updates from the CLI on a separate pc, it is vitally handy to make use of PSWindowsUpdate module for PowerShell. The PSWindowsUpdate shouldn’t be built-in into Windows and is a third-party module obtainable in Technet Script Gallery. PSWindowsUpdate permits directors to remotely test for updates on Windows servers and workstations, set up, take away and conceal sure updates. The PSWindowsUpdate module is very worthwhile to handle Windows updates in Windows Server Core having no graphic interface and through configuration of Windows picture within the audit mode.

PSWindowsUpdate: Installation of the Update Management Module

You can set up PSWindowsUpdate module in Windows 10 and Windows Server 2016 from the net repository utilizing in a single command:

Install-Module -Name PSWindowsUpdate

If you might have an older Windows model (Windows 7/eight.1/ Windows Server 2008 R2/ 2012 R2) otherwise you don’t have direct entry to the Internet, you’ll be able to set up PSWindowsUpdate manually.

This module will be put in on any supported Windows variations beginning from Vista / Windows Server 2008 with PowerShell 2.zero put in (although, PoSh three.zero or later is beneficial).

  1. Download the latest PSWindowsUpdate model from this web page: https://gallery.technet.microsoft.com/scriptcenter/second191bcd-3308-4edd-9de2-88dff796b0bc and the downloaded file; download and unblock the PSWindowsUpdate Module
  2. Extract the module archive into one of many following directories: %USERPROFILEpercentDocumentsWindowsPowerShellModules or %WINDIRpercentSystem32WindowsPowerShellv1.zeroModules (the latter is best if you’ll use the module usually);
  3. Allow scripts execution: Set-ExecutionPolicy RemoteSigned
  4. Import the module to your PowerShell session: Import-Module PSWindowsUpdate. Import-Module PSWindowsUpdate

    Note. In Windows 7 / Server 2008 R2, when importing the PSWindowsUpdate module, the next error might seems: The time period “Unblock-File” shouldn’t be acknowledged because the title of a cmdlet. The matter is that the module makes use of some capabilities that appeared solely in PowerShell three.zero. To use these capabilities, you’ll have both to replace PowerShell or to delete the | Unblock-File line from PSWindowsUpdate.psm1 manually.

If you put in the Windows replace administration PowerShell module in your pc, you’ll be able to remotely set up it on different computer systems and/or servers. Use this script to repeat the module to a number of specified distant servers:

$Targets = "lon-fs02", "lon-db01"
Update-WUModule -LocalPSWUSource "C:Windowssystem32WindowsPowerShellv1.zeroModulesPSWindowsUpdate" -ComputerName $Targets
Invoke-Command -ComputerName $Targets -ScriptBlock

Overview of PSWindowsUpdate Cmdlets

You can show the checklist of obtainable cmdlets within the PSWindowsUpdate module as follows:

get-command -module PSWindowsUpdate

Let’s describe the utilization of the module instructions in short:

  • Get-WindowsUpdate — alias for Get-WUList;
  • Hide-WindowsUpdate – alias for Hide-WUUpdate;
  • Install-WindowsUpdate — alias for Get-WUInstall;
  • Uninstall-WindowsUpdate — alias for Get-WUUninstall;
  • Add-WUOfflineSync – permits to put in updates from the native cache utilizing the file wsusscan.cab or wsusscn2.cab;
  • Add-WUServiceSupervisor – registers the replace server on a pc;
  • Get-WUHistory – shows the checklist of the put in updates;
  • Get-WUInstall – is the principle PSWindowsUpdate cmdlet. It permits to obtain and set up updates from a WSUS server or Microsoft Update. Allows you to pick out replace classes, particular updates and set the principles of a pc restart when putting in the updates;
  • Get-WUInstallerStanding – checks the standing of Windows Installer service;
  • Get-WURebootStatus – lets you test if the restart is required so as a sure replace to be utilized;
  • Get-WUList – shows the checklist of updates that meet the required standards, permits to seek out and set up the replace you want;
  • Get-WUServiceSupervisor – checks the replace supply;
  • Get-WUUninstall – permits to by KB ID;
  • Hide-WUUpdate — lets you cover particular updates from being put in;
  • Invoke-WUInstall – permits to handle distant replace set up;
  • Remove-WUOfflineSync – removes an offline sync supply;
  • Remove-WUServiceSupervisor – removes an replace server.

get-command -module PSWindowsUpdate

PowerShell: List All Windows Updates Available for a Computer

You can show the checklist of obtainable updates to your pc:

Get-WUInstall -ListSolely

Get-WUInstall -ListOnly - list updates available to install on a computer using powershell

To test the checklist of obtainable updates on a distant pc, run this command:

Get-WUList –ComputerName server2

You can test the place your Windows ought to get updates from. Run the next command:


ServiceID IsManaged IsDefault Name
--------- --------- --------- ----
8b24b027-1dee-babb-9a95-3517dfb9c552 False False DCat Flighting Prod
855e8a7c-ecb4-4ca3-b045-1dfa50104289 False False Windows Store (DCat Prod)
3da21691-e39d-4da6-8a4b-b43877bcb1b7 True True Windows Server Update Service
9482f4b4-e343-43b6-b170-9a65bc822c77 False False Windows Update


As you’ll be able to see, the pc is configured to obtain the updates from the native server and Windows Update.

If you need to scan your pc on Microsoft Update servers within the Internet(along with Windows updates, these servers comprise Office and different product updates), run this command:

Get-WUinstall -MicrosoftUpdate –ListSolely

You will get this warning:

Can’t discover registered service Microsoft Update. Use Get-WUServiceSupervisor to get registered service.

To permit scanning on Microsoft Update, run this command:

Add-WUServiceSupervisor -ServiceID "7971f918-a847-4430-9279-4a52d1efe18d" -AddServiceFlag 7

Now you’ll be able to scan your pc on Microsoft Update.

To take away sure merchandise or packages from the checklist of updates obtained by your pc, you’ll be able to exclude them by:

  1. Category (-NotCategory);
  2. Title (-NotCategory);
  3. Update quantity (-NotKBArticleID).

For instance, let’s exclude OneDrive, drivers and the particular KB from the checklist of updates:

Get-WUInstall -NotCategory "Drivers" -NotTitle "OneDrive" -NotKBArticleID KB4489873 -ListSolely

Install Windows Updates Using PSWindowsUpdate Module

To mechanically obtain and set up all obtainable updates to your pc, run the next:

Get-WUInstall -Settle forAll –IgnoreReboot

Get-WUInstall - installing windows update using PSWindowsUpdate Module

The Settle forAll key accepts set up of all packages, and IgnoreReboot permits to suppresses computerized Windows restart after the updates are put in.

You can set up solely the particular replace packages:

Get-WUInstall -KBArticleID KB4489873,KB4489883 –Settle forAll

If you need to take away some updates from the checklist so as to not set up them, run this command:

Get-WUInstall -NotCategory "Drivers" -NotTitle OneDrive -NotKBArticleID KB4489873 -Settle forAll -IgnoreReboot

The module permits you put in updates remotely on a number of workstations or servers (PSWindowsUpdate have to be put in on these pc). It could be very handy since an administrator doesn’t have to go online to all servers when replace set up is scheduled. The following command will set up all obtainable updates (with some exceptions) on three distant servers:

Invoke-WUInstall -ComputerName server1, server2, server1 -Script Out-File C:WindowsPSWindowsUpdate.log -Confirm:$false -Verbose -SkipModuleCheck –RunNow

How to test Windows Update History utilizing PowerShell?

Using the Get-WUHistory cmdlet, you may get the checklist of updates put in on a pc earlier. You can get the details about the date of set up of a sure replace:

Get-WUHistory| Where-Object | Select-Object *|ft

To discover out if the replace has been put in on a number of distant computer systems, you should use this code:

"server1","server2" | Get-WUHistory| Where-Object | Select-Object *|ft

Remove-WindowsUpdate: Uninstalling Windows Updates

To uninstall the updates from PowerShell, you should use the Remove-WindowsUpdate cmdlet. Just specify the KB quantity as an argument of the KBArticleID parameter. To restart your pc later, add the –NoRestart key:

Remove-WindowsUpdate -KBArticleID KB4489873 -NoRestart

How to Hide Windows Updates with PSWindowsUpdate?

You can cover the particular updates so they are going to be by no means put in by Windows Update service in your pc. For instance, to cover the KB4489873 and KB4489883 updates, run these instructions:

$HideList = "KB4489873", "KB4489883"
Hide-WindowsUpdate -KBArticleID $HideList –Hide

Hide-WindowsUpdate - hide kb from installation in windows

Now the subsequent time you scan for updates utilizing the Get-WUInstall –ListSolely command, the hidden updates received’t be displayed within the checklist of updates obtainable for set up.

This is how one can show the checklist of updates hidden on this pc:

Get-WindowsUpdate -IsHidden

To take away an replace from hidden ones, run this command:

Hide-WindowsUpdate -KBArticleID $HideList -Hide:$false

For those that are usually not good at working within the console, I might suggest a graphic  Windows Update MiniTool to handle Windows 10 updates.

Check Also

How to Check If a PowerShell Script Is Run As Administrator?

If you want to run a PowerShell script with the administrator privileges, you possibly can …

Leave a Reply

Your email address will not be published. Required fields are marked *