使用 powershell 更改 IIS SSL 设置
Change IIS SSL settings using powershell
我是 Windows PowerShell 的新手。
我正在尝试更改 IIS 的默认网站的 SSL 设置
Required SSL = false and client certificate = ignore
到
Required SSL = true and client certificate = accept
使用 powershell(我必须将其配置为 ansible playbook)
我已经搜索但没有得到任何解决方案。
请帮忙。任何线索或解决方案将不胜感激。 :)
谢谢
使用 Set-WebConfiguration
cmdlet。有一个很棒的 configuration reference on IIS.NET 可用于查找有效值 - 在本例中为 Ssl
和 SslNegotiateCert
:
Set-WebConfiguration -Location "[sitename]" -Filter 'system.webserver/security/access' -Value 'Ssl,SslNegotiateCert'
实际上,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 实例进行后续更改;你必须先获取另一个实例。
PS:如果你想在弄乱它之前(或之后)查看配置中的内容,权威设置在这里:C:\Windows\System32\inetsrv\config\applicationHost.config
或者你可以继续上面的代码并添加Get-IISConfigAttributeValue -ConfigElement $cfgSection -AttributeName "sslFlags";
我是 Windows PowerShell 的新手。
我正在尝试更改 IIS 的默认网站的 SSL 设置
Required SSL = false and client certificate = ignore
到
Required SSL = true and client certificate = accept
使用 powershell(我必须将其配置为 ansible playbook)
我已经搜索但没有得到任何解决方案。
请帮忙。任何线索或解决方案将不胜感激。 :) 谢谢
使用 Set-WebConfiguration
cmdlet。有一个很棒的 configuration reference on IIS.NET 可用于查找有效值 - 在本例中为 Ssl
和 SslNegotiateCert
:
Set-WebConfiguration -Location "[sitename]" -Filter 'system.webserver/security/access' -Value 'Ssl,SslNegotiateCert'
实际上,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 实例进行后续更改;你必须先获取另一个实例。
PS:如果你想在弄乱它之前(或之后)查看配置中的内容,权威设置在这里:C:\Windows\System32\inetsrv\config\applicationHost.config
或者你可以继续上面的代码并添加Get-IISConfigAttributeValue -ConfigElement $cfgSection -AttributeName "sslFlags";