我一直在尝试在 PowerShell 上运行以下命令:
netsh http add sslcert ipport=0.0.0.0:443 certhash=<some certhash> appid={<random guid>}
问题是,它每次都返回"The parameter is incorrect"
。我已经检查了证书哈希号和生成的 guid,它们都没有问题。事实上,我在 cmd.exe
中运行了相同的命令并且它运行良好,这增加了挫败感。
我想将变量作为 certhash
和 appid
传递,这就是我使用 PowerShell 的原因。
如果有人能帮助我理解为什么它不起作用,或者它是否缺少某些东西才能在 PowerShell 上运行。
最佳答案
我终于知道了问题所在:虽然在 PowerShell 中你可以执行 cmd
native 命令,命令的解析略有变化,在这种情况下,它打乱了 appid
的解释参数(那些大括号!)。
为了解决它,我只是用方括号 ( {}
) 和 <random guid>
括起来在单引号中,因此,
netsh http add sslcert ipport=0.0.0.0:443 certhash=<certhash> appid='{<random guid>}'
与(注意缺少的“引号”)相反,
netsh http add sslcert ipport=0.0.0.0:443 certhash=<certhash> appid={<random guid>}
并且该命令完美运行。
有关 PowerShell 解析的更多信息,Understanding PowerShell Parsing Modes .
关于ssl - 在 PowerShell 上使用 netsh 失败并出现错误 : The parameter is incorrect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9722273/