microsoft / DSCParser

Allows the conversion of DSC scripts into PSObject for analysis purposes
MIT License
29 stars 21 forks source link

ConvertTo-DSCObject not converting correctly a specific property in a blueprint #31

Closed ricmestre closed 1 year ago

ricmestre commented 1 year ago

Given the blueprint at the bottom when converting it to a PSObject a specific property called QuestionText (inside Questions) for some reason is not being converted correctly, whereas every other properties are. Any thoughts on this?

The current output of that property is the following

PS C:\ $Resource.Questions

Name                           Value
----                           -----
CIMInstance                    MSFT_MicrosoftGraphaccesspackagequestion
Sequence                       0
IsRequired                     False
Id                             69e983df-f773-4e0f-ade9-33e83fbfbce2
odataType                      #microsoft.graph.accessPackageTextInputQuestion
IsSingleLineQuestion           True
QuestionText
DefaultText                    Why do you want to be the cool 1234?

Instead it should show the following, including the child property

PS C:\ $Resource.Questions

Name                           Value
----                           -----
CIMInstance                    MSFT_MicrosoftGraphaccesspackagequestion
Sequence                       0
IsRequired                     False
Id                             69e983df-f773-4e0f-ade9-33e83fbfbce2
odataType                      #microsoft.graph.accessPackageTextInputQuestion
IsSingleLineQuestion           True
QuestionText                   {System.Collections.Specialized.OrderedDictionary}

PS C:\ $Resource.Questions.QuestionText

Name                           Value
----                           -----
CIMInstance                    MSFT_MicrosoftGraphaccessPackageLocalizedContent
DefaultText                    Why do you want to be the cool 1234?

And now the blueprint with this issue

Configuration M365TenantConfig
{
    param ()

    $OrganizationName = $ConfigurationData.NonNodeData.OrganizationName

    Import-DscResource -ModuleName 'Microsoft365DSC' -ModuleVersion '1.23.503.1'

    Node localhost
    {
        AADEntitlementManagementAccessPackageAssignmentPolicy "AADEntitlementManagementAccessPackageAssignmentPolicy-Initial Policy"
        {
            AccessPackageId         = "772e529d-f77c-45c8-aec2-62838d940dd1";
            AccessReviewSettings    = MSFT_MicrosoftGraphassignmentreviewsettings{
                IsApprovalJustificationRequired = $True
                ReviewerType = 'Manager'
                IsEnabled = $True
                RecurrenceType = 'quarterly'
                DurationInDays = 25
                StartDateTime = '11/18/2022 22:59:59'
                AccessReviewTimeoutBehavior = 'keepAccess'
                IsAccessRecommendationEnabled = $True
            };
            ApplicationId           = $ConfigurationData.NonNodeData.ApplicationId;
            CanExtend               = $False;
            CertificateThumbprint   = $ConfigurationData.NonNodeData.CertificateThumbprint;
            Description             = "Initial Policy";
            DisplayName             = "Initial Policy";
            DurationInDays          = 0;
            Ensure                  = "Present";
            Id                      = "510fcf5b-9756-4e18-8039-8a606a9f41b5";
            Questions               = @(
                MSFT_MicrosoftGraphaccesspackagequestion{
                    Sequence = 0
                    IsRequired = $False
                    Id = '69e983df-f773-4e0f-ade9-33e83fbfbce2'
                    odataType = '#microsoft.graph.accessPackageTextInputQuestion'
                    IsSingleLineQuestion = $True
                    QuestionText = MSFT_MicrosoftGraphaccessPackageLocalizedContent{
                        DefaultText = 'Why do you want to be the cool 1234?'
                    }
                }
            );
            RequestApprovalSettings = MSFT_MicrosoftGraphapprovalsettings{
                IsRequestorJustificationRequired = $True
                IsApprovalRequired = $True
                ApprovalMode = 'SingleStage'
                ApprovalStages = @(
                    MSFT_MicrosoftGraphapprovalstage1{
                        PrimaryApprovers = @(
                            MSFT_MicrosoftGraphuserset{
                                Id = '8a82928b-486b-4ff6-b652-083fb99104df'
                                odataType = '#microsoft.graph.singleUser'
                                IsBackup = $True
                                ManagerLevel = 1
                            }

                            MSFT_MicrosoftGraphuserset{
                                Id = '6ca2d4f7-0674-4ae0-ad2f-a812f8f8766c'
                                odataType = '#microsoft.graph.requestorManager'
                                IsBackup = $False
                            }
                        )
                        IsEscalationEnabled = $False
                        ApprovalStageTimeOutInDays = 14
                        EscalationTimeInMinutes = 0
                        IsApproverJustificationRequired = $True
                    }
                )
                IsApprovalRequiredForExtension = $False
            };
            RequestorSettings       = MSFT_MicrosoftGraphrequestorsettings{
                AllowedRequestors = @(
                    MSFT_MicrosoftGraphuserset{
                        Id = '331925dc-c11a-4669-9dee-d32882b1d791'
                        odataType = '#microsoft.graph.requestorManager'
                        IsBackup = $true
                    }
                )
                ScopeType = 'SpecificDirectorySubjects'
                AcceptRequests = $True
            };
            TenantId                = $ConfigurationData.NonNodeData.TenantId;
        }
    }
}

M365TenantConfig -ConfigurationData .\ConfigurationData.psd1
NikCharlebois commented 1 year ago

Fixed with 1.0.8

ricmestre commented 1 year ago

Please reopen this issue, the fix just published is for another issue I opened https://github.com/microsoft/Microsoft365DSC/issues/3259

NikCharlebois commented 1 year ago

Fixes with 1.0.9

ricmestre commented 1 year ago

Please reopen this, I've just tested it with 1.3.0.9 and even though the issue is different is still not resolved, now it shows the following below:

PS C:> $Resource.Questions

Name                           Value                                                                                                                                                                        
----                           -----                                                                                                                                                                        
CIMInstance                    MSFT_MicrosoftGraphaccesspackagequestion                                                                                                                                     
Sequence                       0                                                                                                                                                                            
IsRequired                     False                                                                                                                                                                        
Id                             69e983df-f773-4e0f-ade9-33e83fbfbce2                                                                                                                                         
odataType                      #microsoft.graph.accessPackageTextInputQuestion                                                                                                                              
IsSingleLineQuestion           True                                                                                                                                                                         
QuestionText                   {DefaultText}                                                                                                                                                                

PS C:\> $Resource.Questions.QuestionText

Name                           Value                                                                                                                                                                        
----                           -----                                                                                                                                                                        
DefaultText                    Why do you want to be the cool 1234?

As mentioned previously the desired effect is:

PS C:\ $Resource.Questions

Name                           Value
----                           -----
CIMInstance                    MSFT_MicrosoftGraphaccesspackagequestion
Sequence                       0
IsRequired                     False
Id                             69e983df-f773-4e0f-ade9-33e83fbfbce2
odataType                      #microsoft.graph.accessPackageTextInputQuestion
IsSingleLineQuestion           True
QuestionText                   {System.Collections.Specialized.OrderedDictionary}

PS C:\ $Resource.Questions.QuestionText

Name                           Value
----                           -----
CIMInstance                    MSFT_MicrosoftGraphaccessPackageLocalizedContent
DefaultText                    Why do you want to be the cool 1234?

This is most likely the same issue I reported today on https://github.com/microsoft/DSCParser/issues/32, not being able to retrieve deeply nested properties.