2012-03-15 59 views
5

我一直試圖在PowerShell中運行以下命令:在PowerShell中使用netsh的失敗,錯誤:參數不正確

netsh http add sslcert ipport=0.0.0.0:443 certhash=<some certhash> appid={<random guid>} 

的問題是,它返回每次"The parameter is incorrect"。我已經檢查過證書散列號和生成的GUID,它們都沒問題。事實上,我在cmd.exe中運行了相同的命令,它的工作非常完美,這增加了挫折感。

我想通過變量作爲certhashappid,這就是我使用PowerShell的原因。

如果任何人都可以幫助我理解它爲什麼不工作,或者如果在PowerShell上缺少某些功能,

回答

12

我終於明白了問題所在:儘管在PowerShell中,您可以本地執行cmd命令,但命令的解析會稍微改變,並且在這種情況下會中斷參數(大括號!)的解釋。

爲了解決這個問題,我只是封閉的括號({})和單引號<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

+0

謝謝你,我已經浪費了幾個小時就已經:( – 2016-05-19 00:56:15

相關問題