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: Incorrect Type for Language in return value for Get-TargetResource #76

Open
jortencio opened this issue Jul 18, 2023 · 1 comment · May be fixed by #77
Open

UpdateServicesServer: Incorrect Type for Language in return value for Get-TargetResource #76

jortencio opened this issue Jul 18, 2023 · 1 comment · May be fixed by #77

Comments

@jortencio
Copy link

jortencio commented Jul 18, 2023

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

Assuming the current state config of WSUS server:

 Name                           Value                                                                                                                                                                                                                
----                           -----                                                                                                                                                                                                                
Products                       {Office, Windows}                                                                                                                                                                                                    
UpstreamServerSSL                                                                                                                                                                                                                                   
SynchronizeAutomatically       True                                                                                                                                                                                                                 
ContentDir                     C:\WSUS                                                                                                                                                                                                              
UpstreamServerName                                                                                                                                                                                                                                  
UpstreamServerReplica                                                                                                                                                                                                                               
SynchronizationsPerDay         1                                                                                                                                                                                                                    
UpstreamServerPort                                                                                                                                                                                                                                  
ProxyServerBasicAuthentication                                                                                                                                                                                                                      
Ensure                         Present                                                                                                                                                                                                              
Classifications                {e6cf1350-c01b-414d-a61f-263d14d133b4, e0789628-ce08-4437-be74-2495b842f43b}                                                                                                                                         
ProxyServerName                                                                                                                                                                                                                                     
SQLServer                      MICROSOFT##WID                                                                                                                                                                                                       
Languages                      {fr, en}                                                                                                                                                                                                             
ProxyServerPort                                                                                                                                                                                                                                     
UpdateImprovementProgram       False                                                                                                                                                                                                                
ClientTargetingMode            Client                                                                                                                                                                                                               
SynchronizeAutomaticallyTim... 21:00:00                                                                                                                                                                                                             
ProxyServerCredentialUsername   

When running the following code:

 $InvokeParams = @{Name = 'UpdateServicesServer'; Method = 'get'; Property = @{ensure = 'present' }; ModuleName = @{ModuleName = 'C:/Program Files/WindowsPowerShell/Modules/UpdateServicesDsc/1.2.1/UpdateServicesDsc.psd1'; RequiredVersion = '1.2.1' } }

$Result = Invoke-DscResource @InvokeParams -Verbose

$Result 

An error comes up as follows

 A general error occurred that is not covered by a more specific error code.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName        : localhost 

It was identified that the issue was due to the return value for the language being of type StringCollection rather than String[] as per the schema for the UpdateServicesServer resource:

[Write, Description("Update languages, * for all.")] String Languages[]; 

But the current return value is equivalent to the following:

 PS C:\Users\Administrator> (Get-WsusServer).GetConfiguration().GetEnabledUpdateLanguages().GetType()

IsPublic IsSerial Name                                     BaseType                                                                                                                                                                                 
-------- -------- ----                                     --------                                                                                                                                                                                 
True     True     StringCollection                         System.Object    

Verbose logs showing the problem

  VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = Resourceget,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer EC2AMAZ-DUA1E4V with user sid S-1-5-21-2052935279-2926737905-346181576-500.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] Getting WSUS server.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] WSUS server is Present.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] Getting WSUS server configuration.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] Getting WUSS server subscription.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] Getting WSUS SQL server.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] WSUS Server SQL Server is MICROSOFT##WID.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] Getting WSUSServer content directory.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] WSUS Server content directory is C:\WSUS.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] Getting WSUSServer update improvement program.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] WSUS Server content update improvement program is False.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] Getting WSUS Server languages.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] WSUS Server languages are System.Collections.Specialized.StringCollection.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] Getting WSUS Server Classifications.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] WSUS Server Classifications are e6cf1350-c01b-414d-a61f-263d14d133b4.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] Getting WSUS Server products.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] WSUS Server products are Office.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] Getting WSUSServer synchronization settings.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] WSUS Server synchronize automatically is True.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] WSUS Server synchronize automatically time of day is 21:00:00.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] WSUSServer number of synchronizations per day is 1.
VERBOSE: [EC2AMAZ-DUA1E4V]:                            [[UpdateServicesServer]DirectResourceAccess] WSUSServer client targeting mode is Client.
A general error occurred that is not covered by a more specific error code.
    + 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 3.862 seconds 

Suggested solution to the issue

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

The following code in the function Get-TargetResource has been found to be the cause of the issue:

if ($WsusConfiguration.AllUpdateLanguagesEnabled)
{
  $Languages = @('*')
}
else
{
  $Languages = $WsusConfiguration.GetEnabledUpdateLanguages()
}

Write-Verbose -Message ($script:localizedData.WsusLanguages -f $Languages) 

The suggested fix to the issue is as follows:

if ($WsusConfiguration.AllUpdateLanguagesEnabled)
{
  $Languages = @('*')
}
else
{
  $Languages = [String[]]$WsusConfiguration.GetEnabledUpdateLanguages()
}

Write-Verbose -Message ($script:localizedData.WsusLanguages -f ($Languages -join ',')) 

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.3770                                                                                                                                                                                                       
PSEdition                      Desktop                                                                                                                                                                                                              
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                              
BuildVersion                   10.0.17763.3770                                                                                                                                                                                                      
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 
@sooyean-hoo
Copy link

I also having seen issue up close, I will provide some tests to elaborate.
For me, the 2 problematic parameters are

  • Languages
  • Products

UnitTests.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants