首页 > 解决方案 > 相当于`netsh http show sslcert ipport='0.0.0.0:8172'`的powershell

问题描述

我希望进行一些幂等的飞行前检查,并且我想在破坏 SSL 证书之前进行测试。Netsh 似乎已被弃用

“...建议您使用 Windows PowerShell 来管理 Windows Server 2016 和 Windows 10 中的网络技术,而不是 Network Shell...”

我希望只使用 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'...


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

标签: powershelliis

解决方案


要添加端口绑定,请使用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 被导入,这些应该可以正常工作。


推荐阅读