The PSWindowsUpdate module allow you to manage Windows Update on your computer. Module contain set of function to check, download and install or remove update from local machine. Especially useful on machines in core edition like Windows Server 2008 R2 or
later.
Module can be installed manualy by downloading Zip file and extract in two places:
PS > Import-Module PSWindowsUpdate
Windows PowerShell 2.0
v1.5.6
- Added ValidateSet for Severity and NotSeverity params in Install-WindowsUpdate, Get-WindowsUpdate. Added MaxSize and MinSize params in Install-WindowsUpdate, Get-WindowsUpdate.
v1.5.5 - Added RootCategories filter for Install-WindowsUpdate and Get-WindowsUpdate
v1.5.4 - Fixed small bugs
v1.5.3 - Added Severity search option for Install-WindowsUpdate and Get-WindowsUpdate
v1.5.1 - Added Add-WUServiceManager and Remove-WUServiceManager to register/unregister updates Service Manager. Add remoting to Get-WURebootStatus.
v1.5.0 - Added Invoke-WUInstall for pseudo remoting (taskscheduler based - support only for Vista/WS2008 or later) and Update-WUModule to update module.
v1.4.7 - Added AutoSelectOnly param for automatic accept only 'important' updates,
ie those
which have the status AutoSelectOnWebsites = true.
v1.4.6 - Added function Hide-WUUpdate to auto hide updates that meets search criteria.
v1.4.5 - Changed default search pre crteria isHidden = 0 to show only nothidden updates. Added WithHidden param to
get all updates (hidden and not) and removed isNotHidden param (now it is default criteria). Added warning if don't find any updates.
v1.4.4 - Added
NotCategory, NotKBArticleID, NotTitle param to filter updates that's not match of these value.
v1.4.3 - Added isNotHidden
param to show only not hidden updates. Default still show whole updates (hidden and not hidden).
v1.4.2 - Added
IgroneReboot param to hide prompt for reboot, but do not reboot automaticaly.
v1.4.1 - Added
ability to define own search criteria. Correct fast ServerSelection param -WindowsUpdate and -MicrosoftUpdate.
v1.4.0 - Code optimized, new
filtering criteria, simple remote to obtain information about updates.
v1.3.4 - Fixed typographical bug in Get-WUInstall in type of updates.
v1.3.3 - Added progress bar in Get-WUInstall.
v1.3.2 - Fixed small bug in Add-WUOfflineSync.
Depending on the security policy on machine, module may need administrator permissions to use all functions.
Module can use Windows Update offline scan file (I excluded wsusscan.cab file from the module so now need to download it individually). The latest Windows Update offline scan file (wsusscn2.cab) is available from Microsoft Baseline Security Analyzer (MSBA)
or System Management Server Inventory Tool for Microsoft Updates (SMS ITMU).
Examples of using the module (Source code of module is in attachment):
<# .EXAMPLE Get info about updates that are not require user interaction to install. PS C:\> Get-WUInstall -MicrosoftUpdate -IgnoreUserInput -WhatIf -Verbose VERBOSE: Connecting to Microsoft Update server. Please wait... VERBOSE: Found [39] Updates in pre search criteria VERBOSE: Found [5] Updates in post search criteria to Download What if: Performing operation "Aktualizacja firmy Microsoft z ekranem wybierania przeglądarki dla użytkowników systemu Windows 7 dla systemów opartych na procesorach x64 w Europejskim Obszarze Gospodarczym (KB976002)[1 MB]?" on Target "KOMPUTER". What if: Performing operation "Aktualizacja dla systemu Windows 7 dla systemów opartych na procesorach x64 (KB971033)[1MB]?" on Target "KOMPUTER". What if: Performing operation "Aktualizacja systemu Windows 7 dla komputerów z procesorami x64 (KB2533552)[1 MB]?" on Target "KOMPUTER". What if: Performing operation "Program Microsoft .NET Framework 4 Client Profile w systemie Windows 7 dla systemów opartych na procesorach x64 (KB982670)[1 MB]?" on Target "KOMPUTER". What if: Performing operation "Narzędzie Windows do usuwania złośliwego oprogramowania dla komputerów z procesorem x64 -grudzień 2011 (KB890830)[1 MB]?" on Target "KOMPUTER". X Status KB Size Title - ------ -- ---- ----- 2 Rejected KB890830 1 MB Aktualizacja firmy Microsoft z ekranem wybierania przeglądarki dla użytkowników system... 2 Rejected KB890830 1 MB Aktualizacja dla systemu Windows 7 dla systemów opartych na procesorach x64 (KB971033) 2 Rejected KB890830 1 MB Aktualizacja systemu Windows 7 dla komputerów z procesorami x64 (KB2533552) 2 Rejected KB890830 1 MB Program Microsoft .NET Framework 4 Client Profile w systemie Windows 7 dla systemów op... 2 Rejected KB890830 1 MB Narzędzie Windows do usuwania złośliwego oprogramowania dla komputerów z procesorem x6... VERBOSE: Accept [0] Updates to Download .EXAMPLE Get updates from specific source with title contains ".NET Framework 4". Everything automatic accept and install. PS C:\> Get-WUInstall -ServiceID 9482f4b4-e343-43b6-b170-9a65bc822c77 -Title ".NET Framework 4" -AcceptAll X Status KB Size Title - ------ -- ---- ----- 2 Accepted KB982670 48 MB Program Microsoft .NET Framework 4 Client Profile w systemie Windows 7 dla systemów op... 3 Downloaded KB982670 48 MB Program Microsoft .NET Framework 4 Client Profile w systemie Windows 7 dla systemów op... 4 Installed KB982670 48 MB Program Microsoft .NET Framework 4 Client Profile w systemie Windows 7 dla systemów op... .EXAMPLE Get updates with specyfic KBArticleID. Check if type are "Software" and automatic install all. PS C:\> $KBList = "KB890830", "KB2533552", "KB2539636" PS C:\> Get-WUInstall -Type "Software" -KBArticleID $KBList -AcceptAll X Status KB Size Title - ------ -- ---- ----- 2 Accepted KB2533552 9 MB Aktualizacja systemu Windows 7 dla komputerów z procesorami x64 (KB2533552) 2 Accepted KB2539636 4 MB Aktualizacja zabezpieczeń dla programu Microsoft .NET Framework 4 w systemach Windows ... 2 Accepted KB890830 1 MB Narzędzie Windows do usuwania złośliwego oprogramowania dla komputerów z procesorem x6... 3 Downloaded KB2533552 9 MB Aktualizacja systemu Windows 7 dla komputerów z procesorami x64 (KB2533552) 3 Downloaded KB2539636 4 MB Aktualizacja zabezpieczeń dla programu Microsoft .NET Framework 4 w systemach Windows ... 3 Downloaded KB890830 1 MB Narzędzie Windows do usuwania złośliwego oprogramowania dla komputerów z procesorem x6... 4 Installed KB2533552 9 MB Aktualizacja systemu Windows 7 dla komputerów z procesorami x64 (KB2533552) 4 Installed KB2539636 4 MB Aktualizacja zabezpieczeń dla programu Microsoft .NET Framework 4 w systemach Windows ... 4 Installed KB890830 1 MB Narzędzie Windows do usuwania złośliwego oprogramowania dla komputerów z procesorem x6... .EXAMPLE Get list of available updates from Microsoft Update Server. PS C:\> Get-WUList -MicrosoftUpdate ComputerName Status KB Size Title ------------ ------ -- ---- ----- KOMPUTER ------ KB976002 102 KB Aktualizacja firmy Microsoft z ekranem wybierania przeglądarki dla użytkowników... KOMPUTER ------ KB971033 1 MB Aktualizacja dla systemu Windows 7 dla systemów opartych na procesorach x64 (KB... KOMPUTER ------ KB2533552 9 MB Aktualizacja systemu Windows 7 dla komputerów z procesorami x64 (KB2533552) KOMPUTER ------ KB982861 37 MB Windows Internet Explorer 9 dla systemu Windows 7 - wersja dla systemów opartyc... KOMPUTER D----- KB982670 48 MB Program Microsoft .NET Framework 4 Client Profile w systemie Windows 7 dla syst... KOMPUTER ---H-- KB890830 1 MB Narzędzie Windows do usuwania złośliwego oprogramowania dla komputerów z proces... .EXAMPLE Get information about updates from Microsoft Update Server that are installed on remote machine G1. Updates type are software, from specific category, have specific UUID and Revision Name. PS C:\> $UpdateIDs = "40336e0a-7b9b-45a0-89e9-9bd3ce0c3137","61bfe3ec-a1dc-4eab-9481-0d8fd7319ae8","0c737c40-b687-45bc-8deb-83db8209b258" PS C:\> Get-WUList -MicrosoftUpdate -IsInstalled -Type "Software" -CategoryIDs "E6CF1350-C01B-414D-A61F-263D14D133B4" -UpdateID $UpdateIDs -RevisionNumber 101 -ComputerName G1 -Verbose VERBOSE: Connecting to Microsoft Update server. Please wait... VERBOSE: Found [2] Updates in pre search criteria VERBOSE: Found [2] Updates in post search criteria ComputerName Status KB Size Title ------------ ------ -- ---- ----- G1 DI--U- KB2345886 605 KB Aktualizacja dla systemu Windows 7 dla systemów opartych na procesorach x64 (KB... G1 DI--U- KB2641690 67 KB Aktualizacja systemu Windows 7 dla komputerów z procesorami x64 (KB2641690) .EXAMPLE Hide updates contains "Internet Explorer 9" in title and are in "Update Rollups" category. PS C:\> $UpdatesList = Get-WUList -ServiceID "9482f4b4-e343-43b6-b170-9a65bc822c77" -Title "Internet Explorer 9" -Category "Update Rollups" PS C:\> $UpdatesList.IsHidden = $true PS C:\> Get-WUList -ServiceID "9482f4b4-e343-43b6-b170-9a65bc822c77" -Title "Internet Explorer 9" -Category "Update Rollups" -IsHidden ComputerName Status KB Size Title ------------ ------ -- ---- ----- KOMPUTER ---H-- KB982861 37 MB Windows Internet Explorer 9 dla systemu Windows 7 - wersja dla systemów opartyc... .EXAMPLE Show currently available Windows Update Services on machine. PS C:\> Get-WUServiceManager ServiceID IsManaged IsDefault Name --------- --------- --------- ---- 9482f4b4-e343-43b6-b170-9a65bc822c77 False False Windows Update 7971f918-a847-4430-9279-4a52d1efe18d False False Microsoft Update 3da21691-e39d-4da6-8a4b-b43877bcb1b7 True True Windows Server Update Service 13df3d8f-78d7-4eb8-bb9c-2a101870d350 False False Offline Sync Service2 a8f3b5e6-fb1f-4814-a047-2257d39c2460 False False Offline Sync Service #>
<#
.EXAMPLE
Get info about updates that are not require user interaction to install.
PS C:\> Get-WUInstall -MicrosoftUpdate -IgnoreUserInput -WhatIf -Verbose
VERBOSE: Connecting to Microsoft Update server. Please wait...
VERBOSE: Found [39] Updates in pre search criteria
VERBOSE: Found [5] Updates in post search criteria to Download
What if: Performing operation "Aktualizacja firmy Microsoft z ekranem wybierania przeglądarki dla użytkowników systemu Windows 7 dla systemów opartych na procesorach x64 w Europejskim Obszarze Gospodarczym (KB976002)[1 MB]?" on Target "KOMPUTER".
What if: Performing operation "Aktualizacja dla systemu Windows 7 dla systemów opartych na procesorach x64 (KB971033)[1MB]?" on Target "KOMPUTER".
What if: Performing operation "Aktualizacja systemu Windows 7 dla komputerów z procesorami x64 (KB2533552)[1 MB]?" on Target "KOMPUTER".
What if: Performing operation "Program Microsoft .NET Framework 4 Client Profile w systemie Windows 7 dla systemów opartych na procesorach x64 (KB982670)[1 MB]?" on Target "KOMPUTER".
What if: Performing operation "Narzędzie Windows do usuwania złośliwego oprogramowania dla komputerów z procesorem x64 -grudzień 2011 (KB890830)[1 MB]?" on Target "KOMPUTER".
X Status KB Size Title
- ------ -- ---- -----
2 Rejected KB890830 1 MB Aktualizacja firmy Microsoft z ekranem wybierania przeglądarki dla użytkowników system...
2 Rejected KB890830 1 MB Aktualizacja dla systemu Windows 7 dla systemów opartych na procesorach x64 (KB971033)
2 Rejected KB890830 1 MB Aktualizacja systemu Windows 7 dla komputerów z procesorami x64 (KB2533552)
2 Rejected KB890830 1 MB Program Microsoft .NET Framework 4 Client Profile w systemie Windows 7 dla systemów op...
2 Rejected KB890830 1 MB Narzędzie Windows do usuwania złośliwego oprogramowania dla komputerów z procesorem x6...
VERBOSE: Accept [0] Updates to Download
.EXAMPLE
Get updates from specific source with title contains ".NET Framework 4". Everything automatic accept and install.
PS C:\> Get-WUInstall -ServiceID 9482f4b4-e343-43b6-b170-9a65bc822c77 -Title ".NET Framework 4" -AcceptAll
X Status KB Size Title
- ------ -- ---- -----
2 Accepted KB982670 48 MB Program Microsoft .NET Framework 4 Client Profile w systemie Windows 7 dla systemów op...
3 Downloaded KB982670 48 MB Program Microsoft .NET Framework 4 Client Profile w systemie Windows 7 dla systemów op...
4 Installed KB982670 48 MB Program Microsoft .NET Framework 4 Client Profile w systemie Windows 7 dla systemów op...
.EXAMPLE
Get updates with specyfic KBArticleID. Check if type are "Software" and automatic install all.
PS C:\> $KBList = "KB890830", "KB2533552", "KB2539636"
PS C:\> Get-WUInstall -Type "Software" -KBArticleID $KBList -AcceptAll
X Status KB Size Title
- ------ -- ---- -----
2 Accepted KB2533552 9 MB Aktualizacja systemu Windows 7 dla komputerów z procesorami x64 (KB2533552)
2 Accepted KB2539636 4 MB Aktualizacja zabezpieczeń dla programu Microsoft .NET Framework 4 w systemach Windows ...
2 Accepted KB890830 1 MB Narzędzie Windows do usuwania złośliwego oprogramowania dla komputerów z procesorem x6...
3 Downloaded KB2533552 9 MB Aktualizacja systemu Windows 7 dla komputerów z procesorami x64 (KB2533552)
3 Downloaded KB2539636 4 MB Aktualizacja zabezpieczeń dla programu Microsoft .NET Framework 4 w systemach Windows ...
3 Downloaded KB890830 1 MB Narzędzie Windows do usuwania złośliwego oprogramowania dla komputerów z procesorem x6...
4 Installed KB2533552 9 MB Aktualizacja systemu Windows 7 dla komputerów z procesorami x64 (KB2533552)
4 Installed KB2539636 4 MB Aktualizacja zabezpieczeń dla programu Microsoft .NET Framework 4 w systemach Windows ...
4 Installed KB890830 1 MB Narzędzie Windows do usuwania złośliwego oprogramowania dla komputerów z procesorem x6...
.EXAMPLE
Get list of available updates from Microsoft Update Server.
PS C:\> Get-WUList -MicrosoftUpdate
ComputerName Status KB Size Title
------------ ------ -- ---- -----
KOMPUTER ------ KB976002 102 KB Aktualizacja firmy Microsoft z ekranem wybierania przeglądarki dla użytkowników...
KOMPUTER ------ KB971033 1 MB Aktualizacja dla systemu Windows 7 dla systemów opartych na procesorach x64 (KB...
KOMPUTER ------ KB2533552 9 MB Aktualizacja systemu Windows 7 dla komputerów z procesorami x64 (KB2533552)
KOMPUTER ------ KB982861 37 MB Windows Internet Explorer 9 dla systemu Windows 7 - wersja dla systemów opartyc...
KOMPUTER D----- KB982670 48 MB Program Microsoft .NET Framework 4 Client Profile w systemie Windows 7 dla syst...
KOMPUTER ---H-- KB890830 1 MB Narzędzie Windows do usuwania złośliwego oprogramowania dla komputerów z proces...
.EXAMPLE
Get information about updates from Microsoft Update Server that are installed on remote machine G1. Updates type are software, from specific category, have specific UUID and Revision Name.
PS C:\> $UpdateIDs = "40336e0a-7b9b-45a0-89e9-9bd3ce0c3137","61bfe3ec-a1dc-4eab-9481-0d8fd7319ae8","0c737c40-b687-45bc-8deb-83db8209b258"
PS C:\> Get-WUList -MicrosoftUpdate -IsInstalled -Type "Software" -CategoryIDs "E6CF1350-C01B-414D-A61F-263D14D133B4" -UpdateID $UpdateIDs -RevisionNumber 101 -ComputerName G1 -Verbose
VERBOSE: Connecting to Microsoft Update server. Please wait...
VERBOSE: Found [2] Updates in pre search criteria
VERBOSE: Found [2] Updates in post search criteria
ComputerName Status KB Size Title
------------ ------ -- ---- -----
G1 DI--U- KB2345886 605 KB Aktualizacja dla systemu Windows 7 dla systemów opartych na procesorach x64 (KB...
G1 DI--U- KB2641690 67 KB Aktualizacja systemu Windows 7 dla komputerów z procesorami x64 (KB2641690)
.EXAMPLE
Hide updates contains "Internet Explorer 9" in title and are in "Update Rollups" category.
PS C:\> $UpdatesList = Get-WUList -ServiceID "9482f4b4-e343-43b6-b170-9a65bc822c77" -Title "Internet Explorer 9" -Category "Update Rollups"
PS C:\> $UpdatesList.IsHidden = $true
PS C:\> Get-WUList -ServiceID "9482f4b4-e343-43b6-b170-9a65bc822c77" -Title "Internet Explorer 9" -Category "Update Rollups" -IsHidden
ComputerName Status KB Size Title
------------ ------ -- ---- -----
KOMPUTER ---H-- KB982861 37 MB Windows Internet Explorer 9 dla systemu Windows 7 - wersja dla systemów opartyc...
.EXAMPLE
Show currently available Windows Update Services on machine.
PS C:\> Get-WUServiceManager
ServiceID IsManaged IsDefault Name
--------- --------- --------- ----
9482f4b4-e343-43b6-b170-9a65bc822c77 False False Windows Update
7971f918-a847-4430-9279-4a52d1efe18d False False Microsoft Update
3da21691-e39d-4da6-8a4b-b43877bcb1b7 True True Windows Server Update Service
13df3d8f-78d7-4eb8-bb9c-2a101870d350 False False Offline Sync Service2
a8f3b5e6-fb1f-4814-a047-2257d39c2460 False False Offline Sync Service
#>