gpt4 book ai didi

powershell - 如何在 Windows 2016 上使用 Powershell IISAdministration 模块为 IIS 网站设置需要 SSL

转载 作者:行者123 更新时间:2023-12-02 23:02:04 25 4
gpt4 key购买 nike

在 Windows 2016 上,尝试为 Powershell 使用新的 IISAdministration 模块(不是 WebAdministration),如何设置 Require Ssl特定网站的复选框?

system.webserver/security/access 的引用资料发现于 C:\Windows\System32\inetsrv\config\applicationHost.config这是使用 IIS 管理器时保存该复选框值的位置,给定网站的 SSL 设置:

<location path="MySite">
<system.webServer>
<security>
<access sslFlags="Ssl" />
</security>
</system.webServer>
</location>

最佳答案

为后代回答我自己的问题。

IISAdministration 的 New-IISSiteBinding cmdlet 真的让我很困惑。

  • 首先,这不是我的默认 Windows 2016(从 aws 镜像加载)的一部分,因此我必须先执行 Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force 来更新到 IISAdministration 1.1然后 Install-Module -Name IISAdministration -Force .您不能使用更新模块,因为 IISAdministration 1.0 没有随 NuGet 一起安装,它是 Win 2016 的一部分。
  • 二、SslFlag此属性与 SslFlags 无关对于 Require Ssl . SslFlagNew-IISSiteBinding可以设置为None, Sni, CentralCertStore .在IIS管理器中,相当于点击一个网站,然后右边的Bindings链接,然后Add/Edit,勾选“Require Server Name Indication”。

  • IIS 管理 cmdlet Get-IISConfigSection是需要的。以下代码集 Require Ssl在网站上(相当于在 IIS 管理器中单击网站,然后单击 SSL 设置图标,“需要 SSL”复选框):
    Import-Module IISAdministration
    $ConfigSection = Get-IISConfigSection -SectionPath "system.webServer/security/access" -Location "MyWebSite"
    #to set:
    Set-IISConfigAttributeValue -AttributeName sslFlags -AttributeValue Ssl -ConfigElement $ConfigSection
    #to read:
    Get-IISConfigAttributeValue -ConfigElement $ConfigSection -AttributeName sslFlags

    这些也可以通过管道传输。此 sslFlags 的可能值为:None、Ssl、SslNegotiateCert、SslRequireCert、SslMapCert、Ssl128(参见 Access Security access)

    关于powershell - 如何在 Windows 2016 上使用 Powershell IISAdministration 模块为 IIS 网站设置需要 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47909303/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com