Powershell and IIS SSL Bindings (Windows Server 2012/IIS 8.5)

Welcome Forums General PowerShell Q&A Powershell and IIS SSL Bindings (Windows Server 2012/IIS 8.5)

Viewing 2 reply threads
  • Author
    Posts
    • #238415
      Participant
      Topics: 1
      Replies: 1
      Points: -3
      Rank: Member

      This is Windows Server 2012 with IIS 8.5 (yes, it is old, no I can’t just use something newer) I’ve basically figured out how to create the SSL Certificate and Web Bindings, but I’m experiencing a peculiar behavior.

      So, when I do the following ($fqdn is populated earlier):

      $cert = (New-SelfSignedCertificate -DnsName “$fqdn” -CertStoreLocation cert:\LocalMachine\My).Thumbprint

      New-WebBinding -Name “Web_Tools” -Protocol https -IP “*” -Port 443

      $bind = Get-WebBinding -Name “Web_Tools” -Protocol https
      $bind.AddSslCertificate($cert, “My”)

      Everything appears to work, and when I go to IIS Manager I can see everything is set up correctly. However when I try to do:

      Get-ChildItem -Path IIS:\SSLBindings

      I see nothing. I have tried the following:

      • “iisreset /restart”
      • ‘Stop-Website -Name “Web_Tools”; Start-Website -Name “Web_Tools”‘
      • Stopping and Starting World Wide Web Publishing Service from the Service Control Panel.
      • IIS Manager\Web_Tools\Manage Website Stop button followed by the Start button.

      I still see nothing with Get-ChildItem. However, if instead, I use the IIS Manager\Web_Tools\Manage Website Restart button, I can see the appropriate information using Get-ChildItem. Rebooting also helps, but that’s not something I really want to resort to. Obviously the ‘Restart’ button is doing something different than simply Stopping and Starting the Website, but I can’t think of how to figure out what that ‘something’ is.

      The goal is to be able to verify that the ‘AddSslCertificate’ step actually worked and to be able to check whether it was already done previously if the script gets run again.

      I’m not necessarily tied to this method of doing things, as long as I can enable SSL for the “Web_Tools” website specifically since it has a specific CGI configuration that is separate from the default website.

      Any insight or suggestions would be appreciated. Thank you in advance for your time.

      -Jay

    • #238442
      Participant
      Topics: 3
      Replies: 417
      Points: 1,462
      Helping Hand
      Rank: Community Hero

      Can you verify it with

      Get-WebBinding -Name Web_Tools
      

      You should also take a look at IISAdministration module if you haven’t already.

      https://www.powershellgallery.com/packages/IISAdministration/1.1.0.0

    • #238991
      Participant
      Topics: 1
      Replies: 1
      Points: -3
      Rank: Member

      Can you verify it with

      <textarea class=”ace_text-input” style=”opacity: 0; height: 18px; width: 7px; left: 44px; top: 0px;” spellcheck=”false” wrap=”off”></textarea>

      1
      2
      Get-WebBinding Name Web_Tools
      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

      You should also take a look at IISAdministration module if you haven’t already.

      https://www.powershellgallery.com/packages/IISAdministration/1.1.0.0

      Get-WebBinding: Yes, this works fine. I see both http and https defined.

      IISAdministration: To what end? To replace my set/assignment commends, for the get commands, or for the reset commands? Having to download an entire PS module of additional commands to deal with one issue seems a bit extreme but I’m not sure where you think the issue lies that would be addressed by doing so.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.