使用PowerShell更改IIS SSL设置

3

我完全不了解Windows PowerShell。 我正在尝试使用PowerShell(必须配置到ansible playbook)将IIS的默认网站的SSL设置从Required SSL = false and client certificate = ignore更改为Required SSL = true and client certificate = accept。 我已经搜索过,但没有找到任何解决方案。

enter image description here

请帮忙。任何线索或解决方案都将不胜感激。 :) 谢谢

2个回答

12
使用Set-WebConfiguration cmdlet。在IIS.NET上有一个很好的配置参考,您可以使用它来查找有效值-在这种情况下是SslSslNegotiateCert
Set-WebConfiguration -Location "[sitename]" -Filter 'system.webserver/security/access' -Value 'Ssl,SslNegotiateCert'

谢谢。那个链接非常有帮助。这里的“[sitename]”是什么?我应该从哪个位置运行PowerShell? - Mahatma Aladdin
你需要将“[sitename]”替换为要设置的网站、应用程序或虚拟目录的名称或路径。在服务器上以本地管理员身份或被委派管理相关网站/应用程序/虚拟目录的权限的用户身份运行都应该可以。 - Mathias R. Jessen

0

实际上,Set-WebConfiguration 在可靠的方式下不适用于属性。

你应该使用的是:

$cfgSection = Get-IISConfigSection -Location "{siteName}/{appName}" -SectionPath "system.webServer/security/access";
Set-IISConfigAttributeValue -ConfigElement $cfgSection -AttributeName "sslFlags" -AttributeValue "Ssl, SslNegotiateCert";

请注意,在使用Set-IISConfigAttributeValue(并提交更改,如果您正在进行延迟提交)之后,您不能再使用该$cfgSection实例进行后续更改;您需要先获取另一个实例。
附注:如果您想在更改配置之前(或之后)查看其中的内容,则权威设置在此处:C:\Windows\System32\inetsrv\config\applicationHost.config
或者,您可以继续上面的代码并添加Get-IISConfigAttributeValue -ConfigElement $cfgSection -AttributeName "sslFlags";

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接