I'm executing the following command in PowerShell:
Invoke-Expression "openssl pkcs12 -in $certCN.pfx -nocerts -nodes -out $certCN.key -password pass:1111"
It works fine, however the output from openssl
is causing ugly console errors:
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
What's the best way to execute this OpenSSL command and have the output ignored or at least not interpreted as a command?
You don't need Invoke-Expression
(in fact, it's not recommended except in specific cases because it is susceptible to injection). Just run the command and quote the parameters where you need variable string expansion:
openssl pkcs12 -in "$certCN.pfx" -nocerts -nodes -out "$certCN.key" -password pass:1111
To ignore the output of the command, one common technique is to pipe to Out-Null
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With