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

Test-M365DSCParameterState: Function can fail when calling Compare-PSCustomObjectArrays #4952

Closed
ricmestre opened this issue Aug 6, 2024 · 0 comments · Fixed by #4953 or #4998
Closed

Comments

@ricmestre
Copy link
Contributor

Description of the issue

Both CurrentValues and DesiredValues can have properties set to null but if they are fed as input into Compare-PSCustomObjectArrays then the following error message may be triggered. This can be tested with the configuration present here, the error in this case is triggered by the null CIM instance RestrictedApps.

Cannot bind argument to parameter 'CurrentValues' because it is an empty array.
+ CategoryInfo          : InvalidData: (:) [], CimException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyArrayNotAllowed,Compare-PSCustomObjectArrays
+ PSComputerName        : localhost

This issue was actually fixed earlier by @FabienTschanz but during the merge of my fix c274781 the branch wasn't updated and his fix was lost, I'll raise a PR to put it back in.

Microsoft 365 DSC Version

1.24.731.1

Which workloads are affected

Intune

The DSC configuration

IntuneDeviceCompliancePolicyiOs "IntuneDeviceCompliancePolicyiOs-IntuneDeviceCompliancePolicyiOs_1"
        {
            AdvancedThreatProtectionRequiredSecurityLevel  = "unavailable";
            ApplicationId                                  = $IntuneApplicationId;
            Assignments                                    = @(
                MSFT_DeviceManagementConfigurationPolicyAssignments{
                    dataType = '#microsoft.graph.exclusionGroupAssignmentTarget'
                    deviceAndAppManagementAssignmentFilterType = 'none'
                    groupDisplayName = 'DummyGroupExclude'
                    groupId = '053dc89a-be83-411a-bad3-909904b7239e'
                }
                MSFT_DeviceManagementConfigurationPolicyAssignments{
                    dataType = '#microsoft.graph.groupAssignmentTarget'
                    deviceAndAppManagementAssignmentFilterType = 'none'
                    groupDisplayName = 'DummyGroupInclude'
                    groupId = 'b0b8fd3f-af2a-453b-be57-80182d599f02'
                }
            );
            CertificateThumbprint                          = $IntuneCertThumbprint;
            Description                                    = "Apple iOS - Compliance - Standard for Company Users";
            DeviceThreatProtectionEnabled                  = $False;
            DeviceThreatProtectionRequiredSecurityLevel    = "unavailable";
            DisplayName                                    = "IntuneDeviceCompliancePolicyiOs_1";
            Ensure                                         = "Present";
            ManagedEmailProfileRequired                    = $False;
            OsMaximumVersion                               = "15.0";
            OsMinimumVersion                               = "11.0";
            PasscodeBlockSimple                            = $True;
            PasscodeExpirationDays                         = 90;
            PasscodeMinimumLength                          = 6;
            PasscodeMinutesOfInactivityBeforeScreenTimeout = 15;
            PasscodePreviousPasscodeBlockCount             = 5;
            PasscodeRequired                               = $True;
            PasscodeRequiredType                           = "numeric";
            RestrictedApps                                 = @();
            SecurityBlockJailbrokenDevices                 = $True;
            TenantId                                       = $OrganizationName;
        }

Verbose logs showing the problem

Cannot bind argument to parameter 'CurrentValues' because it is an empty array.
+ CategoryInfo          : InvalidData: (:) [], CimException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyArrayNotAllowed,Compare-PSCustomObjectArrays
+ PSComputerName        : localhost

Environment Information + PowerShell Version

Win11 / PS5.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant