Skip to content

UpdateServicesServer: Products fails for "Windows Admin Center" #61

@MartinVokurek

Description

@MartinVokurek

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

The UpdateServicesServer resource fails to configure Products when there are multiple entries returned for a given name (e.g. "Windows Admin Center" is a Product Family as well as Product):

$WsusServer = Get-WsusServer
$AllWsusProducts = $WsusServer.GetUpdateCategories()
$ProductCollection = New-Object Microsoft.UpdateServices.Administration.UpdateCategoryCollection
$Product = 'Windows Admin Center'
$WsusProduct = $AllWsusProducts | Where-Object -FilterScript { $_.Title -eq $Product }

# WsusProduct now contains 2 members:
$WsusProduct


Type                      : ProductFamily
ProhibitsSubcategories    : False
ProhibitsUpdates          : True
UpdateSource              : MicrosoftUpdate
UpdateServer              : Microsoft.UpdateServices.Internal.BaseApi.UpdateServer
Id                        : a871ee2d-7499-6719-3781-8c63a1642990
Title                     : Windows Admin Center
Description               : Product Family for Windows Admin Center
ReleaseNotes              : 
DefaultPropertiesLanguage : 
DisplayOrder              : 2147483647
ArrivalDate               : 2/12/2021 4:37:45 PM

Type                      : Product
ProhibitsSubcategories    : True
ProhibitsUpdates          : False
UpdateSource              : MicrosoftUpdate
UpdateServer              : Microsoft.UpdateServices.Internal.BaseApi.UpdateServer
Id                        : b1b8f641-1ff2-4ae6-b247-4fe7503787be
Title                     : Windows Admin Center
Description               : Windows Admin Center
ReleaseNotes              : 
DefaultPropertiesLanguage : 
DisplayOrder              : 2147483647
ArrivalDate               : 2/12/2021 4:37:45 PM

This causes the following code to fail:

if ($WsusProduct = $AllWsusProducts | Where-Object -FilterScript { $_.Title -eq $Product })
{
$null = $ProductCollection.Add($WsusServer.GetUpdateCategory($WsusProduct.Id))
}

$null = $ProductCollection.Add($WsusServer.GetUpdateCategory($WsusProduct.Id))

Cannot find an overload for "GetUpdateCategory" and the argument count: "1".
At line:1 char:1
+ $null = $ProductCollection.Add($WsusServer.GetUpdateCategory($WsusPro ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest

Verbose logs showing the problem

VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Mi
crosoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer SRV1 with user sid S-1-5-21-2574420874-2490326428-1586090461-500.
VERBOSE: [SRV1]: LCM:  [ Start  Set      ]
VERBOSE: [SRV1]: LCM:  [ Start  Resource ]  [[UpdateServicesServer]WSUS]
VERBOSE: [SRV1]: LCM:  [ Start  Test     ]  [[UpdateServicesServer]WSUS]
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUS server.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS server is Present.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUS server configuration.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WUSS server subscription.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUS SQL server.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS Server SQL Server is MICROSOFT##WID.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUSServer content directory.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS Server content directory is E:\.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUSServer update improvement program.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS Server content update improvement program is False.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUS Server languages.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS Server languages are System.Collections.Specialized.StringCollection.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUS Server Classifications.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS Server Classifications are e6cf1350-c01b-414d-a61f-263d14d133b4.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUS Server products.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS Server products are Windows Server 2016.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUSServer synchronization settings.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS Server synchronize automatically is False.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS Server synchronize automatically time of day is 06:33:59.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUSServer number of synchronizations per day is 1.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUSServer client targeting mode is Server.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Products test failed.
VERBOSE: [SRV1]: LCM:  [ End    Test     ]  [[UpdateServicesServer]WSUS]  in 1.4690 seconds.
VERBOSE: [SRV1]: LCM:  [ Start  Set      ]  [[UpdateServicesServer]WSUS]
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Configuring Wsus.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Check for previous configuration change.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Configuring WSUS Update Improvement Program.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Configuring WSUS for Microsoft Update.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Configuring WSUS no proxy server.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Setting WSUS languages.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Setting WSUS products.
Cannot find an overload for "GetUpdateCategory" and the argument count: "1".
    + CategoryInfo          : NotSpecified: (:) [], CimException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    + PSComputerName        : localhost
 
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Setting WSUS classifications.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Setting WSUS synchronization schedule.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUS server.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS server is Present.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUS server configuration.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WUSS server subscription.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUS SQL server.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS Server SQL Server is MICROSOFT##WID.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUSServer content directory.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS Server content directory is E:\.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUSServer update improvement program.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS Server content update improvement program is False.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUS Server languages.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS Server languages are System.Collections.Specialized.StringCollection.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUS Server Classifications.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS Server Classifications are e6cf1350-c01b-414d-a61f-263d14d133b4.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUS Server products.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS Server products are *.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Getting WSUSServer synchronization settings.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS Server synchronize automatically is False.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUS Server synchronize automatically time of day is 06:33:59.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUSServer number of synchronizations per day is 1.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] WSUSServer client targeting mode is Server.
VERBOSE: [SRV1]:                            [[UpdateServicesServer]WSUS] Products test failed.
Cannot validate argument on parameter 'ErrorRecord'. The argument is null. Provide a valid value for the argument, and then try running the command again.
    + CategoryInfo          : InvalidData: (:) [], CimException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,New-InvalidResultException
    + PSComputerName        : localhost
 
VERBOSE: [SRV1]: LCM:  [ End    Set      ]  [[UpdateServicesServer]WSUS]  in 0.6250 seconds.
The PowerShell DSC resource '[UpdateServicesServer]WSUS' with SourceInfo '::7::9::UpdateServicesServer' threw one or more non-terminating errors while running the Set-TargetResource 
functionality. These errors are logged to the ETW channel called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
    + PSComputerName        : localhost
 
VERBOSE: [SRV1]: LCM:  [ End    Set      ]
The SendConfigurationApply function did not succeed.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName        : localhost
 
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 2.749 seconds

Suggested solution to the issue

Adjust the code to process multiple entries in $WsusProduct separately:

            if ($WsusProduct = $AllWsusProducts | Where-Object -FilterScript { $_.Title -eq $Product })
            {
                $WsusProduct | Foreach-Object -Process {
                    $null = $ProductCollection.Add($_)
                }
            }

Similar change would likely be needed as part of solution to #13

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

Configuration WSUSProduct {
    Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
    Import-DscResource -ModuleName 'UpdateServicesDsc' -ModuleVersion 1.2.1
    
    Node localhost {

        UpdateServicesServer WSUS {
            Ensure = 'Present'
            Languages = 'en'
            Products = 'Windows Admin Center'
        }
    }
}

The operating system the target node is running

OsName               : Microsoft Windows Server 2019 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 1809
WindowsBuildLabEx    : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

Version and build of PowerShell the target node is running

Name                           Value                                                                                                                                                    
----                           -----                                                                                                                                                    
PSVersion                      5.1.17763.1490                                                                                                                                           
PSEdition                      Desktop                                                                                                                                                  
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                  
BuildVersion                   10.0.17763.1490                                                                                                                                          
CLRVersion                     4.0.30319.42000                                                                                                                                          
WSManStackVersion              3.0                                                                                                                                                      
PSRemotingProtocolVersion      2.3                                                                                                                                                      
SerializationVersion           1.1.0.1                                                                                                                                                  

Version of the DSC module that was used

Name              Version Path                                                                                       
----              ------- ----                                                                                       
UpdateServicesDsc 1.2.1   C:\Program Files\WindowsPowerShell\Modules\UpdateServicesDsc\1.2.1\UpdateServicesDsc.psd1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThe issue is a bug.help wantedThe issue is up for grabs for anyone in the community.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions