Adding multiple bindings with xWebAdministration

This topic contains 6 replies, has 5 voices, and was last updated by Profile photo of Palmar Palmar 2 years, 8 months ago.

  • Author
    Posts
  • #16426
    Profile photo of Jim March
    Jim March
    Participant

    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
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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
    Profile photo of Andrea Rizzioli
    Andrea Rizzioli
    Participant

    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
    Profile photo of Palmar
    Palmar
    Participant

    Did you ever find out about the Sslflags option?

  • #19470
    Profile photo of Jim March
    Jim March
    Participant

    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
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    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
    Profile photo of Palmar
    Palmar
    Participant

    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"
            }

You must be logged in to reply to this topic.