I am wondering how to go about setting the web binding to a specific certificate via powershell in IIS.
Example here would be the web binding on the default web site as when I renew the cert and export it in, this will show not selected
For the commands I have seen researching don't seem to work.
Example here
Import-Module Webadministration
$IPAddress = ''
$sitename = "sitename.ca"
Remove-WebBinding -Name "Default Web Site" -Protocol "https" -IPAddress $IPAddress -Port 443 -HostHeader $sitename
New-WebBinding -Name "Default Web Site" -Protocol "https" -IPAddress $IPAddress -Port 443 -HostHeader $sitename -SslFlags 1
$SSLCert = Get-ChildItem –Path "cert:\LocalMachine\My" | Where-Object {$_.subject -like 'cn=sitename.ca' -and $_.Issuer -Like "CN=R3"}
Then the below I have seen to try and add the cert will just give the error Cannot find drive. A drive with the name 'IIS' does not exist
New-Item -Path "IIS:\SslBindings*!443!$sitename" -Value $SSLCert
What is the correct syntax to assign a SSL certificate in the edit site binding via powershell that I am missing?
Any help is greatly appreicated!