Powershell dsc iis bindings - unable to edit bindings after creation

Jessey Clarke 21 Reputation points
2023-01-18T23:14:12.6866667+00:00

Hi

Below is a snippet from a powershell dsc script i am testing with azure automation. It appears to run fine and creates the application pool and website, however the site binding tab within the iis management doesn't show correctly as seen in the screenshots. Nothing in the dropdown and cert isn't visible. Is this normal?

Screenshot 2023-01-18 230912

Screenshot 2023-01-18 231008

PfxImport sslcert
        {
            Thumbprint = '#####################'
            Path       = 'C:\Software\Certificates\cert.pfx'
            Location   = 'LocalMachine'
            Store      = 'My'
            Exportable = $false
            Credential = $Cred
        }

        xWebsite DefaultSite
        {
        Ensure = 'Absent'
        Name = 'Default Web Site'
        DependsOn  = '[WindowsFeature]IIS'
        }

        #Create and configure an application pool.
        xWebAppPool WebAppPool
        {
        Ensure = "Present"
        State = "Started"
        Name = "WebAppPool"
        autoStart = $true
        }

        # Create the new Website with HTTPS
        xWebsite Testsite
        {
        Ensure = 'Present'
        State = 'Started'
        Name = "Testsite"
        ApplicationPool = "WebAppPool"
        PhysicalPath = "F:\IIS\WebAppPool"
        BindingInfo = @(
              @(MSFT_xWebBindingInformation
                    {
                        Protocol = 'HTTPS'
                        Port = 443
                        CertificateThumbprint = '#####################'
                        CertificateStoreName = 'My'
                        HostName = '*.test.net'
                        IPAddress = '*'
                        SSLFlags  = '0'
                    }
                    );
              @(MSFT_xWebBindingInformation
                    {
                        Protocol = 'HTTP'
                        Port = 80
                        IPAddress = '*'
                     }))
        DependsOn = "[xWebAppPool]WebAppPool"
        }
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,134 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Roderick Bant 2,046 Reputation points
    2023-01-19T10:37:45.3466667+00:00

    Hi, thank you for your question at Q&A. I understand you want to create a website secured by TLS certificate in IIS using Desired State Configuration.

    I have not tried your code myself, but I notice 2 things that may be worth checking out. First of all the x in xWebsite leads me to believe you may still be using an older version of the at that time experimental module. So I recommend updating to the more current WebAdministrationDsc module You can install the module to Azure automation from the modules page by clicking the Azure Automation tab on the Installation options there.

    Once you installed the updated module to Azure automation you will have to update your code with the new resource names as the resource names are slightly different in the updated module.

    I think it's also worth adding a dependency to your code to make the Website resource dependant on the creation of the PFX certificate.

    0 comments No comments