microsoft / Microsoft365DSC

Manages, configures, extracts and monitors Microsoft 365 tenant configurations
https://aka.ms/M365DSC
MIT License
1.59k stars 500 forks source link

DSC Parser and Nested Configurations #4644

Closed jadamones closed 1 month ago

jadamones commented 5 months ago

Does DSC Parser 2.0.0.3 handle resources with nested configurations like AADAuthenticationMethodPolicyAuthenticator? If so, how do I compare against those configurations? All I get when convert this to an object is below which doesn't contain all of the settings. Perhaps I missed some documentation somewhere about this?

AADAuthenticationMethodPolicyAuthenticator "AADAuthenticationMethodPolicyAuthenticator-MicrosoftAuthenticator"
{
    ApplicationId         = $ApplicationId
    CertificateThumbprint = $Thumbprint
    Ensure                = "Present"
    Id                    = "MicrosoftAuthenticator"
    IsSoftwareOathEnabled = $True
    State                 = "enabled"
    TenantId              = $TenantId
}
andikrueger commented 4 months ago

Could you share the part of your configuration that would describe the full resource? Thanks!

ssoabx commented 3 months ago

This was also raised here: https://github.com/microsoft/DSCParser/issues/47

edit: sorry for the hijack. this was fixed via https://github.com/microsoft/Microsoft365DSC/issues/4779#issuecomment-2228947648 (since I was running it outside of the regular pipeline..)

I think it's because FeatureSettings as an example parameter isn't set up as an array or the schema isn't properly setup? https://microsoft365dsc.com/resources/azure-ad/AADAuthenticationMethodPolicyAuthenticator/
https://github.com/microsoft/Microsoft365DSC/blob/Dev/Modules/Microsoft365DSC/DSCResources/MSFT_AADAuthenticationMethodPolicyAuthenticator/MSFT_AADAuthenticationMethodPolicyAuthenticator.schema.mof

The parser doesn't know what to do with it as $associatedCIMProperty.CIMType ends up empty
https://github.com/microsoft/DSCParser/blob/master/Modules/DSCParser/Modules/DSCParser.psm1#L648 ...not entirely sure

Example errors

Invoke-Expression : In Zeile:1 Zeichen:63
+ ...                                        $typeStaticMethods = [] | gm - ...
+                                                                  ~
Der Typname nach "[" fehlt.
In Zeile:4 Zeichen:46
+                                             []::TryParse($subExpressi ...
+                                              ~
Der Typname nach "[" fehlt.
In C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.7\Modules\DSCParser.psm1:337 Zeichen:25
+ ...                       Invoke-Expression -Command $scriptBlock | Out-N ...
+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ParserError: (:) [Invoke-Expression], ParseException
    + FullyQualifiedErrorId : MissingTypename,Microsoft.PowerShell.Commands.InvokeExpressionCommand

Example config (from export):

        AADAuthenticationMethodPolicyAuthenticator "AADAuthenticationMethodPolicyAuthenticator-MicrosoftAuthenticator"
        {
            ApplicationId         = $ConfigurationData.NonNodeData.ApplicationId;
            CertificateThumbprint = $ConfigurationData.NonNodeData.CertificateThumbprint;
            Ensure                = "Present";
            FeatureSettings       = MSFT_MicrosoftGraphmicrosoftAuthenticatorFeatureSettings{

                DisplayLocationInformationRequiredState = MSFT_MicrosoftGraphAuthenticationMethodFeatureConfiguration{

                    ExcludeTarget = MSFT_AADAuthenticationMethodPolicyAuthenticatorFeatureTarget{
                        Id = '00000000-0000-0000-0000-000000000000'
                        TargetType = 'group'
                    }

                    IncludeTarget = MSFT_AADAuthenticationMethodPolicyAuthenticatorFeatureTarget{
                        Id = 'all_users'
                        TargetType = 'group'
                    }
                    State = 'default'
                }

                CompanionAppAllowedState = MSFT_MicrosoftGraphAuthenticationMethodFeatureConfiguration{

                    ExcludeTarget = MSFT_AADAuthenticationMethodPolicyAuthenticatorFeatureTarget{
                        Id = '00000000-0000-0000-0000-000000000000'
                        TargetType = 'group'
                    }

                    IncludeTarget = MSFT_AADAuthenticationMethodPolicyAuthenticatorFeatureTarget{
                        Id = 'all_users'
                        TargetType = 'group'
                    }
                    State = 'default'
                }

                DisplayAppInformationRequiredState = MSFT_MicrosoftGraphAuthenticationMethodFeatureConfiguration{

                    ExcludeTarget = MSFT_AADAuthenticationMethodPolicyAuthenticatorFeatureTarget{
                        Id = '00000000-0000-0000-0000-000000000000'
                        TargetType = 'group'
                    }

                    IncludeTarget = MSFT_AADAuthenticationMethodPolicyAuthenticatorFeatureTarget{
                        Id = 'all_users'
                        TargetType = 'group'
                    }
                    State = 'default'
                }

            };
            Id                    = "MicrosoftAuthenticator";
            IncludeTargets        = @(
                MSFT_AADAuthenticationMethodPolicyAuthenticatorIncludeTarget{
                    Id = 'all_users'
                    TargetType = 'group'
                }
            );
            IsSoftwareOathEnabled = $False;
            State                 = "disabled";
            TenantId              = $OrganizationName;
        }
Kierow commented 1 month ago

Can you please perform a winrm quickconfig ? It's now a prerequisite since DSCParser v2 For more information, you can refer to https://github.com/microsoft/Microsoft365DSC/issues/5064