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

[Bug] xGroupResource: Failing if current members list is empty #772

Closed
webalexeu opened this issue Oct 18, 2024 · 1 comment · Fixed by #773
Closed

[Bug] xGroupResource: Failing if current members list is empty #772

webalexeu opened this issue Oct 18, 2024 · 1 comment · Fixed by #773
Labels
bug The issue is a bug.

Comments

@webalexeu
Copy link
Contributor

Problem description

DSC Get function is failing if members list is empty as he is expecting to receive an array and is receiving a null object

Verbose logs

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 NODE with user sid S-1-5-21-299789552-3643019550-3306914009-2117.
VERBOSE: [NODE]:                            [[xGroup]DirectResourceAccess] Invoking the function Get-TargetResourceOnFullSKU for the group Remote Management Users.
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 0.61 seconds

DSC configuration

xGroupResource RemoteManagementUsers
        {
            GroupName        = @("Remote Management Users")
            Ensure           = "Present"
            MembersToInclude = @("administrator")
        }

Suggested solution

This old proposition is resolving the issue #353 (comment)
and will handle all cases possible (empty, single member, multiple members)

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 NODE with user sid S-1-5-21-299789552-3643019550-3306914009-2117.
VERBOSE: [NODE]:                            [[xGroup]DirectResourceAccess] Invoking the function Get-TargetResourceOnFullSKU for the group Remote Management Users.
VERBOSE: [NODE]: LCM:  [ End    Get      ]  [[xGroup]DirectResourceAccess]  in 0.3240 seconds.
VERBOSE: [NODE]: LCM:  [ End    Set      ]    in  1.4680 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.


ConfigurationName    :
DependsOn            :
ModuleName           : C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet_x/xpsdesiredstateconfiguration/dsc_resources/xPSDesiredStateConfiguration/xPSDesiredStateConfiguration.psd1
ModuleVersion        : 9.2.0
PsDscRunAsCredential :
ResourceId           :
SourceInfo           :
Credential           :
Description          : Members of this group can access WMI resources over management protocols (such as WS-Management via the Windows Remote Management service). This applies only to WMI namespaces that grant access to the user.
Ensure               : Present
GroupName            : Remote Management Users
Members              :
MembersToExclude     :
MembersToInclude     :
PSComputerName       : localhost

VERBOSE: Time taken for configuration job to complete is 1.876 seconds

What is your opinion on this so I can prepare the PR according and also add unit testing for this scenario

Thank you

Operating system the target node is running

OsName               : Microsoft Windows Server 2022 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 20348.859.amd64fre.fe_release_svc_prod2.220707-1832
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell version and build the target node is running

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

xPSDesiredStateConfiguration version

Name                         Version Path
----                         ------- ----
xPSDesiredStateConfiguration 9.2.0   C:\ProgramData\PuppetLabs\puppet\cache\lib\puppet_x\xpsdesiredstateconfiguration\dsc_resources\xPSDesiredStateConfiguration\xPSDesiredStateConfiguration.psd1
@johlju johlju added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. labels Oct 18, 2024
@johlju
Copy link
Member

johlju commented Oct 18, 2024

Send in a PR for it, also add tests that validates the change 🙂

@webalexeu webalexeu changed the title xGroupResource: Failing if current members list is empty [Bug] xGroupResource: Failing if current members list is empty Oct 18, 2024
@johlju johlju removed the help wanted The issue is up for grabs for anyone in the community. label Oct 19, 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants