dsccommunity / UpdateServicesDsc

This module contains community maintained DSC resources for deployment and configuration of Windows Server Update Services.
MIT License
31 stars 27 forks source link

[UpdateServicesServer] Products test return false after set #47

Open phoenix2pm opened 4 years ago

phoenix2pm commented 4 years ago

Details of the scenario you tried and the problem that is occurring

Some Wsus products have non ASCII characters in their Title. In particular "Windows Server Manager – Windows Server Update Services (WSUS) Dynamic Installer" dash (" - ") is not in ASCII format therefore comparison is failing subsequently test and set is failing.

Verbose logs showing the problem

Suggested solution to the issue

Suggested solution to strip all none alphanumerical characters using this method: ToCharArray().Where{ $_ -imatch "[a-z0-9]" } -join '' i.e. like this:

foreach ($Product in $Products) {
                    # Due to none ASCII characters used in Product titles in particular "Windows Server Manager – Windows Server Update Services (WSUS) Dynamic Installer" dash (" - ") is not in ASCII format
                    # had to strip all none alphanumerical characters to compare the titles. to do so used this method: ToCharArray().Where{ $_ -imatch "[a-z0-9]" } -join '' 
                    if ($WsusProduct = $AllWsusProducts | Where-Object { ($_.Title.ToCharArray().Where{ $_ -imatch "[a-z0-9]" } -join '') -eq ($Product.ToCharArray().Where{ $_ -imatch "[a-z0-9]" } -join '') }) {
                        Write-Verbose "Setting WSUS Product: $($Product)"
                        $null = $ProductCollection.Add($WsusServer.GetUpdateCategory($WsusProduct.Id))
                    }
                }

The DSC configuration that is used to reproduce the issue (as detailed as possible)

products                          = @(
            'ASP.NET Web and Data Frameworks'
            'ASP.NET Web Frameworks'
            'Azure File Sync agent updates for Windows Server 2016'
            'Windows Server 2016 and Later Servicing Drivers'
            'Windows Server 2016'
            'Windows Server Manager - Windows Server Update Services (WSUS) Dynamic Installer'
        )

The operating system the target node is running

Version and build of PowerShell the target node is running

Version of the DSC module that was used ('dev' if using current dev branch)

master branch version: 1.1.0.0