powershell - 相当于`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'...
是否有一些我最好推荐使用的代码语法/方法?
解决方案
要添加端口绑定,请使用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 被导入,这些应该可以正常工作。
推荐阅读
- javascript - 将数字转换为墨西哥比索字母
- javascript - 如何将验证添加到 textarea 最少 250 和最多 1000 字数?
- node.js - Redis 发布内存泄漏?
- c# - 当我有一个整数数组时,我可以使用 for 循环吗
- cassandra - 插入 NULL 值时如何避免 cassandra 墓碑
- node.js - 在nodejs中为req.session获取“未定义”
- php - ajax 调用后的 Ajax 事件
- javascript - 如何在 JavaScript 中的任何 int 之后添加 n 个零(0)?
- angular - 如何使用 angular2 向客户端读取 JSON
- python - Python:登录模块脚本以在另一个脚本中调用