【问题标题】:powershell equivalent of `netsh http show sslcert ipport='0.0.0.0:8172'`powershell 相当于 `netsh http show sslcert ipport='0.0.0.0:8172'`
【发布时间】:2019-12-08 14:15:07
【问题描述】:

我希望进行一些幂等的飞行前检查,并且我想在破坏 SSL 证书之前进行测试。 Netsh seems to be deprecated,

"...建议您使用Windows PowerShell来管理 Windows Server 2016 和 Windows 10 中的网络技术,而不是 比网络外壳...”

我希望只使用 powershell 模块来配置 IIS。 我已经找到了:


Add-NetIPHttpsCertBinding 替换 netsh http add sslcert ipport='0.0.0.0:8172'...


但找不到类似的东西:


Get-NetIPHttpsCertBinding 替换 netsh http show sslcert ipport='0.0.0.0:8172'...


是否有一些我最好推荐使用的代码语法/方法?

【问题讨论】:

  • 如果Get-NetIPHttpsConfiguration 没有显示它,那么可能是由于 MSFT_NetIpHTTPsConfiguration CIM 类的限制,它只支持AddCertBindingRemoveCertBinding 方法。即使Get-SslCertificateBinding script on powershellgallery.com 仍然依赖于netsh.exe http show sslcert。不管怎样,看看这个possible work-around
  • “Netsh 即将退出” - 需要参考。
  • Netsh 仍然是 Windows Server 2019,在我拥有的所有其他内部版本以及 Windows 内部客户端中。所以,我也想知道为什么有人会说“Netsh 即将退出市场”。特别是,在 MS 声明所有 cmd.exe/DOS 的东西在可预见的未来都将在操作系统中之后,因为他们对 Windows PowerShell 有 sado。当然,没有更多的新工作进入他们,但他们会在那里。然而,当然,他们希望所有人都使用 PowerShell。
  • 尽管文档建议使用 powershell 命令,但似乎微软还没有发布解决方法 powershell 命令。 Netsh http show sslcert 仍然是显示所有 ssl 证书绑定的唯一方法。 IISadministration 只能用于显示 IIS https 绑定及其证书。现在文档说仍然支持网络外壳,我认为您可以继续使用网络外壳。
  • social.technet.microsoft.com/Forums/en-US/… "在未来的 windows 版本中,微软可能会删除 TCP/IP 的 netsh 功能。如果您当前使用 netsh 配置和管理 TCP/IP,微软建议您过渡到 Windows Powershell"

标签: powershell iis


【解决方案1】:

要添加端口绑定,请使用Add-NetIPHttpsCertBinding。理论上。看来这个小程序并不容易使用。如果你改用netsh http add sslcert 命令,它可能表示失败(文件已经存在),但是当我尝试它时,它仍然添加了绑定。

要列出或删除端口,请尝试以下操作。

Import-Module WebAdministration;

$ipPort = 0.0.0.0:4002;

$result = Get-ChildItem -path IIS:\SSLbindings\$ipPort;
$result = Remove-Item -path IIS:\SSLbindings\$ipPort;

只要 WebAdministration 被导入,这些应该可以正常工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-06
    • 2011-05-16
    • 1970-01-01
    相关资源
    最近更新 更多