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

DSC_CertReq failed to execute Set-TargetResource functionality with error message: Cannot add type. The type name 'Source.NativeMethods' already exists #270

Open
heinejeppesen opened this issue Nov 18, 2022 · 0 comments

Comments

@heinejeppesen
Copy link

heinejeppesen commented Nov 18, 2022

Problem description

I'm trying to upgrade our dev environments to Windows Server 2022 and I need to get certificate from a new WS2022 based PKI.

Deployment is through Azure DevOps pipeline and Azure Automation DSC on Azure VMs.

The error comes every time the pipeline runs, deploying from scratch.
When looking at the DSC State in Azure Automation, the state becomes compliant at the second run, so almost immediately after pipeline has completed.

I can't force the error again, by testing manually, so I can't trigger the error once the initial deployment has succeeded.
Log info is what I get returned from AZ CLI through the pipeline.

Everything works, but for some reason the DSC fails the initial runs but succeeds at second run.

Verbose logs

PowerShell DSC resource DSC_CertReq failed to execute Set-TargetResource functionality with error message: Cannot add type. The type name 'Source.NativeMethods' already exists

DSC configuration

#Check if a reboot is required before requesting certificates
        PendingReboot BeforeCertReq {
            Name             = "BeforeCertReq"
            DependsOn        = '[Script]ConfigureSendConnector'
        }

        ##Get Exchange Certificate
        CertReq SSLCert {
            Subject                 = "mail.$($domainName)"
            CAType                  = "Enterprise"
            KeyLength               = '2048'
            Exportable              = $true
            CertificateTemplate     = "$($environment)LabWebServer"
            SubjectAltName          = "dns=autodiscover.$($domainName)&dns=smtp.$($domainName)&dns=ews.$($domainName)"
            AutoRenew               = $true
            FriendlyName            = "mail.$($domainName)"
            Credential              = $domainAdminCredentialNetBios
            DependsOn               = "[PendingReboot]BeforeCertReq"
        }

Suggested solution

N/A

Operating system the target node is running

Server 2022 (unpatched at the failure time)

PowerShell version and build the target node is running

5.1 (Server 2022 built-in)

CertificateDsc version

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

No branches or pull requests

1 participant