【发布时间】:2021-03-29 02:04:41
【问题描述】:
我正在尝试将 PS5 脚本更新到 PS7,主要是因为该脚本确实需要 PS Core 模块才能工作。
部分脚本涉及更新 IIS 绑定以使用不同的 SSL 证书。证书在商店中,可以使用 - 我只需要更改绑定上的指纹。
我的 PS5 脚本使用 Get-WebConfiguration 来获取绑定,然后循环执行,在相关绑定上调用 RebindSslCertificate。
我尝试过使用 Set-WebConfigurationProperty 和 Set-WebBinding;既没有错误,但也没有真正更新与 IIS 的绑定 - 示例:
Set-WebConfigurationProperty -Name 'certificateHash' -Value $newCert.Thumbprint -PSPath "IIS:\\" `
-Filter "/system.applicationHost/sites/site/bindings/binding[@protocol='https'][@bindingInformation='*:443:hostname']" `
谁能帮我指出我所缺少的正确方向?
谢谢, 标记。
PS,抱歉,如果这是一个重复的问题,但我只能找到不起作用或与 "-Set-Item IIS:\SslBindings" 相关的旧东西也许有办法让 IIS 驱动器与远程处理一起工作?
【问题讨论】:
-
您使用的是哪个版本的 IIS?如果您使用的是 IIS 7,还需要安装 powershell 管理单元以支持 IIS 7powershell:iis.net/downloads/microsoft/powershell
-
请先以管理员身份运行powershell。在尝试运行 powershell 脚本之前,请记住先导入 Web 管理:“Import-Module WebAdministration”。
-
我正在使用 IIS 10 并且 Powershell 以管理员身份运行。我完全糊涂了。
-
如果我使用其他命令会起作用吗?
-
我找到了一篇关于PowerShell管理IIS网站绑定的博客,可以参考:4sysops.com/archives/manage-iis-website-bindings-in-powershell
标签: powershell ssl iis powershell-remoting