在PowerShell中运行openssl命令

多米尼克·布鲁内蒂(Dominic Brunetti)

我正在PowerShell中执行以下命令:

Invoke-Expression "openssl pkcs12 -in $certCN.pfx -nocerts -nodes -out $certCN.key -password pass:1111"

它工作正常,但是来自的输出openssl导致难看的控制台错误:

openssl : MAC verified OK
At line:1 char:1
+ openssl pkcs12 -in www.mywebsite.com.pfx -nocerts -node ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (MAC verified OK:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

执行此OpenSSL命令并忽略输出或至少不将其解释为命令的最佳方法是什么?

多米尼克·布鲁内蒂(Dominic Brunetti)

在我发布此消息五分钟后,我发现了这篇文章:

http://www.jonathanmedd.net/2013/07/making-native-executables-in-windows-run-quietly-in-powershell.html

简单地显示

2>&1 

在字符串末尾将成功和错误重定向为null,例如:

 Invoke-Expression "openssl pkcs12 -in $certCN.pfx -nocerts -nodes -out $certCN.key -password pass:1111" 2>&1

可以根据我的需要工作。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章