Dom*_*tti 6 windows powershell command
我在PowerShell中执行以下命令:
Invoke-Expression "openssl pkcs12 -in $certCN.pfx -nocerts -nodes -out $certCN.key -password pass:1111"
Run Code Online (Sandbox Code Playgroud)
它工作正常,但输出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
Run Code Online (Sandbox Code Playgroud)
执行此OpenSSL命令并忽略输出或至少不将其解释为命令的最佳方法是什么?
您不需要Invoke-Expression(事实上,除特殊情况外,不建议使用,因为它易于注射).只需运行命令并引用需要变量字符串扩展的参数:
openssl pkcs12 -in "$certCN.pfx" -nocerts -nodes -out "$certCN.key" -password pass:1111
Run Code Online (Sandbox Code Playgroud)
要忽略命令的输出,一种常见的技术是管道Out-Null.
| 归档时间: |
|
| 查看次数: |
14204 次 |
| 最近记录: |