powershell - 尝试将绑定添加到 IIS 站点时,我返回:“配置对象是只读的”
问题描述
我已将我的 Powershell 脚本放在下面。我正在从自签名证书 ($ca) 创建一个 HTTPS 证书 ($httpsk)。当我运行脚本时,它在“New-IISSiteBinding”上失败。总的来说,这应该是创建 2 个证书(检查),然后使用其中一个证书
$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"
我得到的错误是:
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
我查看了堆栈溢出、Microsoft 和几个第三方站点,但找不到任何关于此的内容。有类似的东西可能对您有所帮助。它的问题略有不同,它是 C# 而不是 PowerShell 脚本。这是链接。究竟是什么问题,我该如何解决?我是 IIS 的半新手。当它说“配置对象”时,它指的是什么?是证书、站点还是绑定?
解决方案
您可以根据本网站检查您的命令格式错误是否导致问题。
这是供参考:New-IISSiteBinding
推荐阅读
- wpf - WPF ScrollViewer 更改 TextBlock 宽度
- c++ - pugiXML 将现有节点附加到文档中
- json - PayPal 传入 JSON 请求未映射到 API 请求
- python - 创建不包括列表中所有值的随机数
- c++ - 使用标准模板编程混淆 C++ 函数调用
- html - YouTube 嵌入视频播放器尺寸仍然太小
- kubernetes - 如何释放 kubernetes 集群中的 kubelet pod 空间
- git - 混帐添加。添加所有更改,包括忽略的文件
- arrays - Redux:将项目添加到数组会改变初始状态
- c++ - Direct2D 渲染到命令列表和打印:图片压缩