Adding multiple bindings with xWebAdministration

Welcome Forums DSC (Desired State Configuration) Adding multiple bindings with xWebAdministration

This topic contains 6 replies, has 5 voices, and was last updated by

 
Participant
4 years ago.

  • Author
    Posts
  • #16426

    Participant
    Points: 0
    Rank: Member

    I'm having trouble figuring out the syntax to add multiple bindings...

        xWebsite CSLWebsite
        {
            Name = $name
            Ensure = $ensure
            PhysicalPath = $DestinationPath
            ApplicationPool = $Name
            State = 'Started'
            BindingInfo = MSFT_xWebBindingInformation
                        {
                            Port = '80'
                            IPAddress = '*'
                            HostName = $hostheader.ToLower()
                            Protocol = 'HTTP'
                        }
            DependsOn = "[File]WebSitePath"
    }

    It doesn't look like there is anyway to add the SSL flags to the binding either...

  • #16429

    Keymaster
    Points: 1
    Rank: Member

    Ping @stevenmurawski on Twitter if this doesn't help, but...

    First, check out the community version of this module in our DSC Hub (in the Git repo). I know it accepts a thumbprint for a certificate, for example. And I think you have to create multiple configuration items for each binding. The "c" versions are usually less buggy and more-featured than the "x" versions; the guys have been enhancing the "x" versions as they use them in production.

  • #17283

    Participant
    Points: 0
    Rank: Member

    The below worked for me:

    $sitename = "MainWebSite" 
    xWebsite MainHTTPWebsite  
    {  
        Ensure          = "Present"  
        Name            = $sitename
        ApplicationPool = "MainAppPool" 
        State           = "Started"  
        PhysicalPath    = "C:\path\to\files"  
        BindingInfo     = @(
                            @(MSFT_xWebBindingInformation   
                                {  
                                    Protocol              = "HTTP"
                                    Port                  =  80 
                                    HostName              = "www.domain.tld"
                                }
                            );
                            @(MSFT_xWebBindingInformation
                                {
                                    Protocol              = "HTTPS"
                                    Port                  = 443
                                    HostName              = "www.domain.tld"
                                }
                            )
                          )
        #DependsOn       = "[File]copyWebFiles"  
    }  
    
  • #19325

    Participant
    Points: 0
    Rank: Member

    Did you ever find out about the Sslflags option?

  • #19470

    Participant
    Points: 0
    Rank: Member

    Looking at my script right now, and I don't see anything in there.

    Honestly, I can't remember why I was needing to do that in the first place...

  • #19473

    Member
    Points: 0
    Rank: Member

    There's no way to pass in an SslFlags value with Microsoft's original "x" version of the resource, but we have a cWebAdministration version up on the PowerShell.org GitHub site, and you could add it to that. (Should be pretty straightforward to add an extra property to the DSC resource and pass it along to the underlying IIS commands.)

  • #19508

    Participant
    Points: 0
    Rank: Member

    I ended up doing this with a script.

            Script setSSLflags
            {
                SetScript = {
                    Set-WebBinding -Name $websitename -BindingInformation $bindinginformation -PropertyName sslFlags -Value 3
                }
                TestScript = {
                    [bool][[get-webbinding -name $websitename | where {$_.bindingInformation -like "*443:*"}].sslFlags -eq 3]
                }
                GetScript = {
                    $webbindingresult = [get-webbinding -name $websitename | where {$_.bindingInformation -like "*443:*"}].sslFlags
                    Return @{
                        Result = "sslFlags = $webbindingresult"
                    }
                }
                DependsOn = "[xWebsite]yourwebsite"
            }

The topic ‘Adding multiple bindings with xWebAdministration’ is closed to new replies.