Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

Error exporting AADEntitlementManagementAccessPackageAssignmentPolicy when Access Reviews are not configured

Open jadamones opened this issue 1 year ago • 3 comments

Description of the issue

If access review settings are not configured on an entitlement policy, it seems like the key is not being dropped and is instead returning invalid results. Setting $Results.AccessReviewSettings = "@{}"; instead of $Results.Remove('AccessReviewSettings') | Out-Null resolves the issue on the Export-TargetResource function but not sure if that's a valid long term fix.

### Original 

                $complexTypeStringResult = Get-M365DSCDRGComplexTypeToString `
                    -ComplexObject $Results.AccessReviewSettings `
                    -CIMInstanceName MicrosoftGraphassignmentreviewsettings `
                    -ComplexTypeMapping $complexMapping
                if ($complexTypeStringResult)
                {
                    $Results.AccessReviewSettings = $complexTypeStringResult
                }
                else
                {
                    $Results.Remove('AccessReviewSettings') | Out-Null
                }
            }

### Working

                $complexTypeStringResult = Get-M365DSCDRGComplexTypeToString `
                    -ComplexObject $Results.AccessReviewSettings `
                    -CIMInstanceName MicrosoftGraphassignmentreviewsettings `
                    -ComplexTypeMapping $complexMapping
                if ($complexTypeStringResult)
                {
                    $Results.AccessReviewSettings = $complexTypeStringResult
                }
                else
                {
                    $Results.AccessReviewSettings = "@{}";
                }
            }
            else
            {
                $Results.AccessReviewSettings = "@{}";
            }

Microsoft 365 DSC Version

v1.25.319.1

Which workloads are affected

Azure Active Directory (Entra ID)

The DSC configuration

AADEntitlementManagementAccessPackageAssignmentPolicy "AADEntitlementManagementAccessPackageAssignmentPolicy-Initial Policy"
    {
        AccessPackageId         = "Test Entitlement - Members (External)";
        AccessReviewSettings    = MSFT_MicrosoftGraphassignmentreviewsettings{
            Count = 0
            IsFixedSize = $False
            IsReadOnly = $False
            IsSynchronized = $False
            SyncRoot = System.Object
        };
        ApplicationId           = $ApplicationId;
        CanExtend               = $False;
        CertificateThumbprint   = $Thumbprint;
        Description             = "Initial Policy";
        DisplayName             = "Initial Policy";
        DurationInDays          = 0;
        Ensure                  = "Present";
        Id                      = "9bab03a6-e845-49ad-a063-08a102480061";
        RequestApprovalSettings = MSFT_MicrosoftGraphapprovalsettings{
            ApprovalMode = "NoApproval"
            IsRequestorJustificationRequired = $False
            IsApprovalRequiredForExtension = $False
            IsApprovalRequired = $False
        };
        RequestorSettings       = MSFT_MicrosoftGraphrequestorsettings{
            ScopeType = "NoSubjects"
            AcceptRequests = $False
        };
        TenantId                = $TenantId;
    }

Verbose logs showing the problem

member 'IsFixedSize' is not valid. Valid members are
'AccessReviewTimeoutBehavior', 'DurationInDays', 'IsAccessRecommendationEnabled', 'IsApprovalJustificationRequired', 'IsEnabled', 'RecurrenceType', 'Reviewers', 'ReviewerType', 'StartDateTime'.

Environment Information + PowerShell Version


jadamones avatar Mar 21 '25 20:03 jadamones

I've fixed this for us by changing the if statement on rule 948 to : if ($null -ne $Results.AccessReviewSettings -and $Results.AccessReviewSettings.Count -ne 0) and the one in the get-targetresource : on rule 137 to
if ($null -ne $formattedAccessReviewSettings -and $formattedAccessReviewSettings.Count -ne 0)

Since the current if statement will always give a true because the hashtable has a {} in it.

AndromeHyperion avatar Apr 03 '25 09:04 AndromeHyperion

Working on a fix

ykuijs avatar Apr 08 '25 10:04 ykuijs

We have a similar issue on 1.25.430.1 The member 'Count' is not valid. Valid members are 'AccessReviewTimeoutBehavior', 'DurationInDays', 'IsAccessRecommendationEnabled', 'IsApprovalJustificationRequired', 'IsEnabled', 'RecurrenceType', 'Reviewers', 'ReviewerType', 'StartDateTime'.

Doesn't appear to like all this stuff

Image

Sheep-NZ avatar May 06 '25 21:05 Sheep-NZ