Selecting products for synchronization using the WSUS console is relatively cumbersome. With PowerShell, you can filter them by search terms and then decide to subscribe or cancel the synchronization. The classifications can also be handled in this way.

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.

Connect to the WSUS server and list all products

Connect to the WSUS server and list all products

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 filter using the TitleIncludes parameter then Get WsusProduct performs a substring search

If you filter using the TitleIncludes parameter then Get WsusProduct performs a substring search

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.

Retrieving dependent product categories using the GetUpdateCategories method

Retrieving dependent product categories using the GetUpdateCategories method

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.

Display products you have already subscribed to

Display products you have already subscribed to

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.

Subscribe to a product in WSUS using Set WsusProduct

Subscribe to a product in WSUS using Set WsusProduct

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.

Listing classifications in WSUS with Get WsusClassification

Listing classifications in WSUS with Get WsusClassification

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.

avatar
0 Comments

Leave a reply

Please enclose code in pre tags

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2021

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account