How To Use PowerShell To Manage Windows Updates
How To Use PowerShell To Manage Windows Updates
com/blog
September 2, 2020
By Roman Fattakhov (https://www.parallels.com/blogs/ras/author/roman-fattakhov/)
Last updated on May 6, 2022
s/ras/author/roman-fattakhov/)
0 (https://www.parallels.com/blogs/ras/powershell-windows-update/#comments)
Installing Windows update patches has always been a tedious, complex, and long process. Although Microsoft eases these procedures through tools such
as Windows Server Update Services (WSUS) or System Center Configuration Manager (SCCM), administrators still require command-line tools to automate (h
ttps://4sysops.com/archives/install-windows-updates-remotely-with-the-powershell/) the installation of the update in certain scenarios. The PowerShell Wind
ows Update module (https://petri.com/manage-windows-updates-with-powershell-module), or PSWindowsUpdate, is one such tool.
1. Download the latest PSWindowsUpdate version from the PowerShell gallery. (https://www.powershellgallery.com/)
**Previous versions of the module are also available in the Microsoft Technet Gallery, but Microsoft has retired this repository and now remains in read-
only mode.
2. Create a new folder named “PSWindowsUpdate” in %WINDIR%\System32\WindowsPowerShell\v1.0\Modules and extract the content of the nupkg
file.
**A NuGet package is a ZIP archive with some extra files. Some browsers, like Internet Explorer, automatically replace the .nupkg file extension with
.zip
3. Open an elevated PowerShell prompt and run Set-ExecutionPolicy RemoteSigned to allow the execution of scripts signed by a trusted publisher.
If the PowerShell setup is already configured to allow online downloads, the PSWindowsUpdate module can also be installed directly from the online
repository (PSGallery) running Install-Module -Name PSWindowsUpdate.
Commands in PSWindowsUpdate
Installed aliases and cmdlets can be displayed by typing Get-Command–module PSWindowsUpdate.
Get-WindowsUpdate: This is the main cmdlet of the module. It lists, downloads, installs, or hides a list of updates meeting predefined requisites and sets
the rules of the restarts when installing the updates.
Get-WULastResults: Gets the dates for the last search and installation of updates.
Like for all PowerShell cmdlets, different usage examples can be shown for each command by typing Get-Help “command” -examples.
Filtering Updates:
AcceptAll: Downloads or installs all available updates.
KBArticleID: Finds updates that contain a KBArticleID (or sets of KBArticleIDs).
UpdateType: Finds updates with a specific type, such as ‘Driver’ and ‘Software.’ Default value contains all updates.
Get-WUList
To hide a specific update using the KB number, use your mouse to copy that KB number. Next, type the command below:
Highlight the “KB_Number” and click paste to replace that part with the actual KB number.
When prompted to confirm the action, type A, and hit the Enter key. If the command succeeds, the “Get-WUList” lists all the available updates, with hidden
updates appearing with the symbol “H” under their status.
The KB number for the update may not be available for some updates. In this case, you can use the title to hide the update. To do this, list all the available
updates via the cmdlet below:
Get-WUList
Next, use your mouse to copy the update title. Ensure it is distinct from other update titles. Now, type below command below to hide the update:
Don’t forget to paste the actual update title in the “Update Title” section.
When prompted to confirm the action, type A, and hit the Enter key. If the command succeeds, the “Get-WUList” lists all the available updates. However,
the status of hidden updates appears with the symbol “H” underneath them.
Centralizing all of the computer logs and analyzing them to search for errors, administrators will always be able to know the patch level of their Windows
computers and servers.
To check where a computer gets its updates from, run the Get-WUServiceManager command. If you see a Windows Server Update Service = True in the
results, that means that it is set to receive updates from your WSUS server.
To get a list of updates for a remote server or computer, run Get-WUList –Computername computername. For example, Get-WUList –ComputerName
server1.
If you need updates for Microsoft Office and other Microsoft products, you can also scan for updates from Microsoft Update servers by running Get-WUList –
MicrosoftUpdate. If you get a warning, run Add-WUServiceManager -ServiceID “7971f918-a847-4430-9279-4a52d1efe18d” -AddServiceFlag 7, then run the
command again.
To install all updates without getting approval prompts for each package, run Install-WindowsUpdate –AcceptAll. To ignore reboots at the end without a
prompt, add an –IgnoreReboot switch at the end, e.g., Install-WindowsUpdate –AcceptAll –IgnoreReboot.
Invoke-WUInstall -ComputerName server1, server2-Script {ipmo PSWindowsUpdate; Get-WUInstall -AcceptAll -AutoReboot | Out-File
C:\Windows\PSWindowsUpdate.log } -Confirm:$false -Verbose -SkipModuleTest –RunNow
Flexible PowerShell management with Parallels RAS
Parallels® Remote Application Server (RAS) (https://www.parallels.com/products/ras/remote-application-server/) is a remote work solution that provides 24/7
virtual access to applications and desktops from any device.
Many administrators decide to build their Parallels RAS farms based on templates to optimize the new machine’s deployment time and management efforts.
When working with templates and cloning techniques, patching procedures are only done once in the master image. Deploying new machines based on the
updated template will upgrade the environment within minutes.
Parallels RAS PowerShell SDK (Software Development Kit) includes a complete set of tools to manage and configure RAS farms, including specific cmdlets to
create templates from existing virtual machines or deploy new machines based on those templates. By combining these commands with the
PSWindowsUpdate PowerShell module, administrators will be able to automate the complete patching process of their infrastructure servers and their
template-based machines.
Different RAS cmdlets can be used to automate the updates installation processes, as seen in this example: Parallels RAS PowerShell – VDI Example (https://
download.parallels.com/ras/v17/docs/en_US/Parallels-RAS-v17-PowerShell-Guide/samples/vdi.html?_gl=1*m296s3*_gcl_aw*R0NMLjE1OTE4NjkxNzMuRUF
JYUlRb2JDaE1JX09LNjVMNzU2UUlWUkozVkNoM1N5Z0ttRUFBWUFTQUFFZ0w2TF9EX0J3RQ..).
The complete set of RAS commands is available here: Parallels RAS PowerShell Reference (https://www.parallels.com/products/ras/resources/#ParallelsRAS
PowerShellGuide).
See how Parallels RAS can simplify the Windows Updates management process!
(https://www.youtube.com/ParallelsTV?autoplay=1)
© 2024 Parallels International GmbH. For more info, please check Legal Notices (/about/legal/)
Features
Application Publishing (https://www.parallels.com/products/ras/capabilities/vdi-virtual-desktop-delivery/?utm_source=blogs-ras&utm_medium=blogs&utm_campaign=blogs-
ras&utm_content=ras&utm_content=powershell-windows-update)
Remote Desktops & VDI (https://www.parallels.com/products/ras/capabilities/vdi-solutions/?utm_source=blogs-ras&utm_medium=blogs&utm_campaign=blogs-
ras&utm_content=ras&utm_content=powershell-windows-update)
Load Balancing (https://www.parallels.com/products/ras/capabilities/load-balancing/?utm_source=blogs-ras&utm_medium=blogs&utm_campaign=blogs-
ras&utm_content=ras&utm_content=powershell-windows-update)
Parallels Client (https://www.parallels.com/products/ras/capabilities/rdp-client/?utm_source=blogs-ras&utm_medium=blogs&utm_campaign=blogs-
ras&utm_content=ras&utm_content=powershell-windows-update)
Reporting (https://www.parallels.com/products/ras/capabilities/secure-remote-access/?utm_source=blogs-ras&utm_medium=blogs&utm_campaign=blogs-
ras&utm_content=ras&utm_content=powershell-windows-update)
Client Management (https://www.parallels.com/products/ras/capabilities/windows-client-management/?utm_source=blogs-ras&utm_medium=blogs&utm_campaign=blogs-
ras&utm_content=ras&utm_content=powershell-windows-update)
Automated Configuration (https://www.parallels.com/products/ras/capabilities/cloud-automation/?utm_source=blogs-ras&utm_medium=blogs&utm_campaign=blogs-
ras&utm_content=ras&utm_content=powershell-windows-update)
HTML5 (https://www.parallels.com/products/ras/capabilities/html5-rdp-client/?utm_source=blogs-ras&utm_medium=blogs&utm_campaign=blogs-
ras&utm_content=ras&utm_content=powershell-windows-update)