- Join Windows 11 to an Active Directory domain - Thu, Jun 1 2023
- Change Windows network profiles between public and private - Wed, May 24 2023
- How to map a network drive with PowerShell - Wed, May 17 2023
A look at the WSUS console shows that the list of products to which you can subscribe for updates is quite extensive. Many of them also contain various versions and components as subcategories. In addition, they are not always presented in a consistent manner, and a search function is missing.
Filtering products
First, connect to the WSUS server using Get-WsusServer. In the next step, query the products with the Get-WsusProduct cmdlet:
$WSUS = Get-WsusServer -Name <WSUS-FQDN> -PortNumber 8531 -UseSsl Get-WsusProduct -UpdateServer $WSUS
If you're working on the console of the WSUS server, you can omit the UpdateServer parameter.
The above example for Get-WsusProduct displays the entire list of available products, including the first level and its subcategories. You can narrow the results by using the TitleIncludes parameter:
Get-WsusProduct -TitleIncludes "System Center"
This command looks for all products that have System Center in the title. However, dependent entries on the second level, in which this term does not appear, remain hidden. In the case of System Center, this applies to the Azure Backup Server, for example.
If you want to query a category exactly by name and display its related products, proceed as follows:
$Prod = Get-WsusProduct | where{ $\_.Product.Title -eq "System Center"} $Prod;$prod.Product.GetSubcategories() | Format-Table Title, ID
The first command only returns the main category System Center. The GetSubcategories () method can be used to obtain its subordinate entries.
Display already selected products
Before you subscribe to a product using PowerShell, you probably want to see whether you have already selected it for synchronization. The products activated in the WSUS server can be obtained as follows:
$WSUS.GetSubscription().GetUpdateCategories() | select title
The output does not distinguish between levels; instead, you just get a flat list of all the entries you have marked in the console.
Subscribing to products
Once you have found the products you want, you can subscribe to them using Set-WsusProduct. For this purpose, pipe the output of Get-WsusProduct to Set-WsusProduct:
Get-WsusProduct -TitleIncludes "Office" | Set-WsusProduct
Usually, you will not want to make such a rough assignment, as dozens of products contain the term "Office." Therefore, it makes sense to specify the exact names in TitleIncludes or to use the following command:
Get-WsusProduct | where{ $\_.Product.Title -eq " System Center 2019 - Orchestrator"} | Set-WsusProduct
If you want to ensure that the wrong products are not included in the list, run Set-WsusProduct first with the WhatIf switch.
If you filter subcategories using the GetSubcategories() method, as shown above, you cannot pass the result to Set-WsusProduct. This is because it outputs objects of the UpdateCategory type, but the cmdlet expects WsusProduct.
Products can also be deselected by using Set-WsusProduct. To do this, use the Disable switch. Otherwise, the procedure is the same as for subscribing:
Get-WsusProduct | where{ $\_.Product.Title -eq " System Center 2019 - Orchestrator"} | Set-WsusProduct -Disable
Selecting classifications
The task is much easier when managing update classifications. These are just a handful of entries, and they don't have subcategories. To find out which ones you have already selected, use this command:
$WSUS.GetSubscription().GetUpdateClassifications() | select title
If you are working on the WSUS server and have not assigned the $WSUS variable, then enter
(Get-WsusServer).GetSubscription().GetUpdateClassifications() | select title
You can display the list of available classifications with Get-WsusClassification. It doesn't offer a parameter to filter the entries.
You could activate a specific classification like this:
Subscribe to 4sysops newsletter!
Get-WsusClassification | Where {$\_.Classification.Title -eq "Definition Updates"} | Set-WsusClassification
To activate or cancel the subscription for updates in a specific classification, you can use Set-WsusClassification. Like its counterpart for products, it includes the Disable switch to deselect classifications.