locked
New-Website with Ssl and SslFlags RRS feed

  • Question

  • In PowerShell 4, we create a new website using New-Website with -Ssl and -SslFlags provided. -SslFlags is typically set to 0. We also supply a value for -HostHeader. Sometimes, this creates a website with an https binding that has the proper certificate associated with the binding. Other times, the https binding has no certificate associated with it, even though the certificate is visible in the certificate drop-down box.

    What are the requirements for having -Ssl and -SslFlags associate a certificate with an https binding?

    Tuesday, October 10, 2017 11:43 PM

All replies

  • Hi,

    Based on the tests in my lab, the same behavior reproduced.
    I’d like to explain that there might have no built-in parameter in New-Website to select the certificate for binding. In this case, I recommend you could have a try with the following scripts to change the ssl binding certificate. Hope it is helpful to you:
    $cert = Get-ChildItem -Path 'Cert:\LocalMachine\My' | Where-Object {$_.Subject -match '<Certificate Subject>'}
    $binding = Get-WebBinding -Name '<Website Name>'
    $binding.AddSslCertificate($cert.GetCertHashString(),'My')

    If you need further help, please feel free to let us know.

    Best Regards,
    Albert Ling

    Please remember to mark the replies as an answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, October 11, 2017 2:37 AM
  • Thank you for responding and for recommending the script.

    Am I understanding correctly, you were able to use -Ssl and -SslFlags with New-Website to create a website with an https binding that had a certificate associated with it, for some cases but not all?

    Wednesday, October 11, 2017 2:39 PM
  • Hi,

    Based on my research, I'd like to explain that if you need to bind a specific certificate for a website, you might need to use both New-Website and Get-WebBinding to achieve that.

    If you need further help, please feel free to let us know.

    Best Regards,
    Albert Ling

    Please remember to mark the replies as an answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, October 13, 2017 9:00 AM
  • Hi,

    Just checking in to see if the information provided was helpful.

    Please let us know if you would like further assistance.

    Best Regards,
    Albert Ling

    Please remember to mark the replies as an answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Thursday, October 19, 2017 8:58 AM
  • Thanks, Albert. We are using the combination of New-Website and Get-WebBinding.
    Friday, October 20, 2017 5:54 PM
  • Hi,

    I am checking how the issue is going, if you still have any questions, please feel free to contact us.

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.
    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
    If no, please reply and tell us the current situation in order to provide further help.

    Appreciate for your feedback.

    Best Regards,
    Albert Ling

    Please remember to mark the replies as an answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Tuesday, October 24, 2017 2:08 AM