Latest posts by Michael Pietroforte (see all)
- Author and member of the year 2019 – Why DevOps still doesn't rule the IT world - Wed, Jan 1 2020
- Results of the 4sysops member and author competition in 2018 - Tue, Jan 8 2019
- Why Microsoft is using Windows customers as guinea pigs - Reply to Tim Warner - Tue, Dec 18 2018
- Get-WUList: Get a list of available updates that meet certain criteria
- Get-WUInstall: Download and install updates
- Add-WUOfflineSync: Register offline scanner service
- Remove-WUOfflineSync: Unregister offline scanner service
- Get-WUServiceManager: Display Service Manager configuration
- Get-WUHistory: Get a list of previous updates
- Get-WUInstallerStatus: Check Windows Update Installer status
- Get-WURebootStatus: Check Windows Update reboot status
- Get-WUUninstall: Uninstall update
After Miroslav recommended PSWindowsUpdate in a comment, I tried Michal Gajda’s PowerShell module. I was surprised at how versatile its functions are. The only requirement is that you have at least PowerShell 2.0 installed.
If you want to try the cmdlets at the PowerShell prompt, you have to import the module first. To do so, extract the zip file to your PowerShell module folder ($HOME\Documents\WindowsPowerShell\Modules ) and then import the module with the Import-Module cmdlet.
WARNING: To run some commands exposed by this module on Windows Vista, Windows Server 2008, and later versions of Windows, you must start an elevated Windows PowerShell console.
Of course, you can also just use the module’s functions in your scripts without importing them. Once the module is imported, you have the following cmdlets at your disposal.
Get-WUList: Get a list of available updates that meet certain criteria ^
If you just want to get an overview of the available updates or to search for updates, this cmdlet will be helpful.
Get-WUInstall: Download and install updates ^
This cmdlet is the core of the PowerShell module. It comes with quite a few parameters. You can choose whether the updates are downloaded from your WSUS server or from Microsoft Update. You can specify updates or categories, configure the reboot behavior, and do much more.
Add-WUOfflineSync: Register offline scanner service ^
This function allows you to install updates from a local cache. You can work with either the old wsusscan.cab or the new wsusscn2.cab. If you want to automate the download of the CAB file, you should look at this PowerShell script.
Remove-WUOfflineSync: Unregister offline scanner service ^
If you registered the offline scanner service with Add-WUOfflineSync, you can use this function to unregister the service.
Get-WUServiceManager: Display Service Manager configuration ^
Sometimes you have to check which update service is configured on the computer (Windows Update, Microsoft Update, WSUS, or offline sync service).
Get-WUHistory: Get a list of previous updates ^
You can list the installed updates on either a local machine or a remote one.
Get-WUInstallerStatus: Check Windows Update Installer status ^
This cmdlet verifies that the Windows Installer is ready. You might want to check this at the beginning of your scripts.
Get-WURebootStatus: Check Windows Update reboot status ^
You can use this command in scripts to determine if a specific update requires a reboot.
Get-WUUninstall: Uninstall update ^
This cmdlet takes an update ID as input and uninstalls the corresponding update.
At the beginning of each function, you’ll find a detailed description, a list of parameters, and examples.
The advantage of PSWindowsUpdate over the two update command-line tools I discussed previously (WuInstall and ABC-Update) is that you can easily integrate PSWindowsUpdate’s functions in your PowerShell scripts. If you work with another scripting solution, you might prefer one of the other two tools.