You can use the Windows Update tool to keep your system updated with the most recent security fixes and enhancements. However, you may sometimes want to have more control over how and when Windows Update runs on your computer. For example, you may want to manually check for updates, install only certain updates, or schedule updates to run at a convenient time.
How to use PowerShell to manage Windows Update
To use PowerShell to manage Windows Update third-party module called PSWindowsUpdate is normally used. With the help of the PSWindowsUpdate module, you may use PowerShell to customize Windows Update in Windows. It provides more functionality and flexibility than the built-in Windows Update settings, such as listing, installing, hiding, viewing, and scheduling updates. You must install the PSWindowsUpdate module from the PowerShell Gallery in order to utilize it. To accomplish this, run the following command:
Run the following command to view the PSWindowsUpdate module’s available cmdlets:
Check for Available Windows Updates with PowerShell
Use the Get-WindowsUpdate or Get-WUList cmdlet to see if any updates are currently available for your PC before installing Windows updates using PowerShell:
This command will return a list of updates that apply to your device. You can also use filters to search for updates in specific categories, such as software or security. For example:
This command will return only software updates but here in the above image I do not have one so the command is not showing any.
Installing Available Windows Updates with PowerShell
PowerShell may now be used to automatically download and install all Windows updates from the Windows Update servers and for that execute:
These commands will download and install all the updates that apply to your device and automatically reboot the computer to apply the changes.
Installing Specific Windows Updates with PowerShell
Instead of installing all of the Windows’s updates, you might wish to do so occasionally. In this case, you can use the -KBArticleID parameter to specify the KB information of the update you want to install.This is useful in the case if you have missed any of the security update then you can get the knowledge base (KB) ID from the Microsoft catalog and then use the below syntax:
Viewing the Windows Update History with PowerShell
You might want to use PowerShell to view the history of Windows updates and the Get-WUHistory cmdlet can be used to accomplish this:
This command will return a list of updates that were installed on your device previously, along with their status, date, and source.
Removing Specific Windows Updates with PowerShell
In some cases, faults or troubles may make you decide to uninstall previously applied Windows updates. The uninstall-WindowsUpdate cmdlet can be used in this situation, and you can give the KB information of the update you want to uninstall. For example:
This command will remove the update with the KB number KB without restarting the computer.
Additionally, you can prevent the Windows Update servers from installing a particular Windows update on your machine by hiding it. The following commands, for instance, can be used to hide the KB5005565 update.
Get-WindowsUpdate -KBArticleID $HideList -Hide
Conclusion
To use PowerShell to manage Windows Update use the PSWindowsUpdate module. Through this module you can perform common tasks with Windows Update, such as checking, installing, hiding, viewing, and removing updates. You can use PowerShell to manage Windows Update more efficiently and effectively than using the graphical user interface.