我正在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命令并忽略输出或至少不将其解释为命令的最佳方法是什么?
在我发布此消息五分钟后,我发现了这篇文章:
简单地显示
2>&1
在字符串末尾将成功和错误重定向为null,例如:
Invoke-Expression "openssl pkcs12 -in $certCN.pfx -nocerts -nodes -out $certCN.key -password pass:1111" 2>&1
可以根据我的需要工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句