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

EXOAcceptedDomain: MatchSubDomains ValidateScript fails #1779

Closed
Kirikou974 opened this issue Feb 22, 2022 · 0 comments · Fixed by #1798 or #1813
Closed

EXOAcceptedDomain: MatchSubDomains ValidateScript fails #1779

Kirikou974 opened this issue Feb 22, 2022 · 0 comments · Fixed by #1798 or #1813

Comments

@Kirikou974
Copy link
Contributor

Kirikou974 commented Feb 22, 2022

Details of the scenario you tried and the problem that is occurring

I have an EXO configuration that I am trying to test with DSC (Test-DscConfiguration).
When I run the test I get an error message for the EXOAcceptedDomains objects that I have.
Example of EXOAcceptedDomain that passes the test without error :

        EXOAcceptedDomain [someID]
        {
            ApplicationId         = $ConfigurationData.NonNodeData.ApplicationId;
            CertificateThumbprint = $ConfigurationData.NonNodeData.CertificateThumbprint;
            DomainType            = "InternalRelay";
            Ensure                = "Present";
            Identity              = "somedomain.fr";
            MatchSubDomains       = $False;
            OutboundOnly          = $False;
            TenantId              = $ConfigurationData.NonNodeData.TenantId;
        }

Example that fails :

       EXOAcceptedDomain [someID]
        {
            ApplicationId         = $ConfigurationData.NonNodeData.ApplicationId;
            CertificateThumbprint = $ConfigurationData.NonNodeData.CertificateThumbprint;
            DomainType            = "InternalRelay";
            Ensure                = "Present";
            Identity              = "somedomain.fr";
            MatchSubDomains       = $True;
            OutboundOnly          = $False;
            TenantId              = $ConfigurationData.NonNodeData.TenantId;
        }

Verbose logs showing the problem

Log generated when I have the error :
##[error]PowerShell DSC resource MSFT_EXOAcceptedDomain failed to execute Test-TargetResource functionality with error
message: Cannot validate argument on parameter 'MatchSubDomains'. The " $false -eq $_ " validation script for the
argument with value "True" did not return a result of True. Determine why the validation script failed, and then try
the command again.

Suggested solution to the issue

I looked into MSFT_EXOAcceptedDomain.psm1 and it looks like there a difference between what's documented and the actual behavior.
The documentation says :
The MatchSubDomains parameter must be false on Authoritative domains. The default value is false.
https://microsoft365dsc.com/resources/exchange/EXOAcceptedDomain/

The ValideScript doesn't take the "DomainType" into account.
It just says :

        [Parameter()]
        [ValidateScript( { $false -eq $_ })]
        [System.Boolean]
        $MatchSubDomains = $false,

I think one way to fix it would be to remove the ValidateScript completely and test the value in regards to the DomainType in the processing part of the Test-TargetResource function.

The DSC configuration that is used to reproduce the issue (as detailed as possible)

       EXOAcceptedDomain [someID]
        {
            ApplicationId         = $ConfigurationData.NonNodeData.ApplicationId;
            CertificateThumbprint = $ConfigurationData.NonNodeData.CertificateThumbprint;
            DomainType            = "InternalRelay";
            Ensure                = "Present";
            Identity              = "somedomain.fr";
            MatchSubDomains       = $True;
            OutboundOnly          = $False;
            TenantId              = $ConfigurationData.NonNodeData.TenantId;
        }

The operating system the target node is running

Windows 10

Version of the DSC module that was used ('dev' if using current dev branch)

1.22.209.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants