Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MartinVokurek opened this issue Feb 12, 2021 · 5 comments · Fixed by #71 · May be fixed by #64
Open

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

MartinVokurek opened this issue Feb 12, 2021 · 5 comments · Fixed by #71 · May be fixed by #64
Labels
bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community.

Comments

@MartinVokurek
Copy link

MartinVokurek commented Feb 12, 2021

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
@MartinVokurek
Copy link
Author

The same applies to UpdateServicesApprovalRule resource, the solution should ideally fix both resources:

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

MartinVokurek pushed a commit to MartinVokurek/UpdateServicesDsc that referenced this issue Feb 12, 2021
@MartinVokurek
Copy link
Author

When testing this, I found an additional related issue with verbose output of Products at line 157. If there are multiple Products selected, only the first one is displayed.

Write-Verbose -Message ($script:localizedData.WsusProducts -f $Products)

Proposed fix (already included in the commit):

Write-Verbose -Message ($script:localizedData.WsusProducts -f ($Products -join ', '))

@NicolasBn
Copy link
Member

I reopen this issue because PR #71 doesn't cover UpdateServicesApprovalRule resource.

@NicolasBn NicolasBn reopened this Sep 4, 2022
@jordanjthomas
Copy link

Has there been any progress on this issue? Still having problems with this error for UpdateServicesApprovalRule resource.

@misskecupbung
Copy link

I got the same issue

@johlju johlju added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. labels Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community.
Projects
None yet
5 participants