How To Create An IIS Website In PowerShell With SSL Encryption
Creating an IIS website in PowerShell can be done fairly easily using the New-Website command but when coupled with the requirement to allow clients to connect over HTTPS (SSL), it adds a layer of complexity to the mix.
In this snip, we’ll go over how to not only create a website with the New-Website cmdlet, but explain a little about how web bindings work using the Get-WebBinding and New-WebBinding cmdlets. We’ll then create a self-signed certificate using the New-SelfSignedCertificate cmdlet and finish it off by using the IIS provider to assign our newly created certificate thumbprint to the SSL binding.
Prerequisites include: IIS10 on Windows Server 2016 (might work on 2012R2) IIS WebAdministration PowerShell Module