Category filter
PowerShell scripts for Windows patch management
To ensure a safe and reliable digital workspace, Windows devices must be updated with the most recent security updates and bug fixes. However, managing patches across many systems can be time-consuming and prone to human error. A patch management script can be helpful in this situation.
It helps to automate the execution of instructions that streamline downloading, installing, and managing patches on Windows computers. This can save time, reduce the likelihood of human error, and ensure consistency across all computers in the network. With a patch management script executed using Hexnode’s Execute Custom Script feature, you can also automate the process of identifying vulnerabilities or downloading and installing of required updates.
PowerShell script
You can use the PSWindowsUpdate module to streamline the process of Windows patch management.
Module installation
To install the PSWindowsUpdate module on your computer (manual installation required).
1 |
Install-Module –Name PSWindowsUpdate |
List available cmdlets
To display the list of available cmdlets in the PSWindowsUpdate module.
1 |
Get-Command -Module PSWindowsUpdate |
List available updates
To get a full list of available Windows updates (Alias: Get-WUList).
1 |
Get-WindowsUpdate |
Install updates
1 |
Get-WUInstall –AcceptAll |
1 |
Get-WUInstall -KBArticleID ‘Article number’ |
Eg: Get-WUInstall -KBArticleID KB4011670
Uninstall updates
To uninstall an already installed update (Alias: Get-WUUninstall).
1 |
Uninstall-WindowsUpdate -KBArticleID ‘Article number’ |
Disable automatic downloads
To prevent the device from downloading updates automatically.
1 |
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "NoAutoUpdate" -Value 1 |