【问题标题】:Change IIS SSL settings using powershell使用 powershell 更改 IIS SSL 设置
【发布时间】:2018-01-08 01:15:46
【问题描述】:

我对 Windows PowerShell 完全陌生。 我正在尝试将 IIS 的默认网站的 SSL 设置从 Required SSL = false and client certificate = ignoreRequired SSL = true and client certificate = accept 使用 powershell(我必须将其配置为 ansible playbook) 我已经搜索但没有得到任何解决方案。

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

【问题讨论】:

    标签: windows powershell iis ansible powershell-2.0


    【解决方案1】:

    使用Set-WebConfiguration cmdlet。有一个很棒的 configuration reference on IIS.NET 可用于查找有效值 - 在本例中为 SslSslNegotiateCert

    Set-WebConfiguration -Location "[sitename]" -Filter 'system.webserver/security/access' -Value 'Ssl,SslNegotiateCert'
    

    【讨论】:

    • 谢谢。该链接是一个很大的帮助。这里的“[站点名称]”是什么?我应该从哪个位置运行 PowerShell?
    • 在 [sitename] 的位置,您应该输入网站名称或要为其设置的应用程序或虚拟目录的路径。作为本地管理员或已被委派管理相关站点/应用程序/vdir 权限的用户在服务器上运行应该这样做
    【解决方案2】:

    实际上,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";

    【讨论】:

      猜你喜欢
      • 2021-03-29
      • 2018-07-09
      • 2012-08-13
      • 1970-01-01
      • 1970-01-01
      • 2018-10-24
      • 1970-01-01
      • 1970-01-01
      • 2012-07-06
      相关资源
      最近更新 更多