I have put my Powershell Script below. I am creating an HTTPS certificate ($httpsk) from a self-signed certificate ($ca). When I run the script, It fails on the "New-IISSiteBinding." Overall, this should be creating 2 certificates (check) and then using one of those certificates
$ca = New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My `
-FriendlyName $Name -DnsName $Name `
-KeyusageProperty All -KeyUsage CertSign, CRLSign, DigitalSignature `
-KeyAlgorithm RSA -KeyLength 4096 -NotAfter (Get-Date).AddYears(20)
# Generate HTTPS certificate issued by the self-signed CA
$httpsk = New-SelfSignedCertificate -CertStoreLocation cert:\LocalMachine\My `
-FriendlyName "$FriendlyNameHTTPS" `
-DnsName $DnsNameHTTPS `
-KeyAlgorithm RSA -KeyLength 2048 -Signer $ca -NotAfter (Get-Date).AddYears(3)
Write-Warning "Generated a certificate which may be used for the HTTPS binding."
Export-Certificate -FilePath "C:\temp\certificate" -Cert $ca | Out-Null
$thumbprint = $httpsk.thumbprint
$websiteName = "Default Web Site"
New-IISSiteBinding -Name $websiteName -BindingInformation "*:443:$domainName" -CertificateThumbPrint $thumbprint -CertStoreLocation "cert:\LocalMachine\my" -Protocol "https"
The error I get is:
New-IISSiteBinding : The configuration object is read only, because it has been committed by a call to ServerManager.CommitChanges(). If
write access is required, use ServerManager to get a new reference.
At line:1 char:5
+ New-IISSiteBinding -Name $websiteName -BindingInformation "*:443" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-IISSiteBinding], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.IIS.Powershell.Commands.NewIISSiteBindingCommand
I looked around stack overflow, Microsoft, and several third party sites but cannot find anything on this. There was something similar that might be helpful for you to look at. It's with a slightly different problem and it was C# rather than a PowerShell script. Here is the link. What exactly is the problem and how do I fix it? I'm semi-new to IIS. What is it referring to when it says the "configuration object"? is that the certificate, the site, or the binding?