Pasting a command line into VSCode's integrated terminal executes part of it prematurely - powershell

when I copy my code into terminal in VScode . terminal executes my code before my code finish copying.
keytool -list -v \
-alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore
how to turn off this feature
sorry my english is bad, i use google translate.

Your integrated terminal in Visual Studio Code is running PowerShell, which doesn't support use of \ as a line-continuation character.
Either use ` (a backtick), making sure that it is the very last character on the line, or paste the command as a single line.
Additionally, PowerShell doesn't understand %USERPROFILE% as an environment-variable reference (only cmd.exe does); use $env:USERPROFILE instead.
Therefore:
With line continuation:
keytool -list -v `
-alias androiddebugkey -keystore $env:USERPROFILE\.android\debug.keystore
Single-line:
keytool -list -v -alias androiddebugkey -keystore $env:USERPROFILE\.android\debug.keystore

Related

How do I execute a command with a new .exe in powershell

I want to decrypt a file that is AES encryptet, with a script on powershell. To decrypt it I want to use a openSSL binary, that the script automatically downloads.
When I execute the openssl.exe with start-Process -FilePath "$pwd\openssl\openssl.exe" a new cmd-window opens and I can enter my command to decrypt the file there. (which works I have tested it)
So my question:
Is there a way to execute the command openssl aes-256-cbc -d -a -in secrets.txt.enc -out secrets.txt.new with the .exe without having to manually input it into the new window?
Yes, try this:
& ".\openssl\openssl.exe" aes-256-cbc -d -a -in secrets.txt.enc -out secrets.txt.new
Using Start-Process, you can pass the parameters with -ArgumentList:
Start-Process -FilePath "$pwd\openssl\openssl.exe" -ArgumentList "aes-256-cbc -d -a -in secrets.txt.enc -out secrets.txt.new"

How to delete multiple certs from keystore

I have one keystore which has around 30 certificates i want to delete most of them.
How can i do it rather than doing keytool -delete -alias <AliasName> -keystore keystore.jks

Powershell openssl ObjectNotFound in windows server 2012

while trying to convert the private key file in PKCS12 format to PEM format (which is used by Wireshark) in two stages by using the openssl tool got the below error
PS C:\OpenSSL-Win64\bin> openssl pkcs12 -nodes -in test_cer123456.pfx -out key.pem -nocerts -nodes
openssl : The term 'openssl' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
+ openssl pkcs12 -nodes -in test_cer123456.pfx -out key.pem -nocerts -nodes
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (openssl:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [3,General]: The command openssl was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by
default. If you trust this command, instead type ".\openssl". See "get-help about_Command_Precedence" for more details.
PS C:\OpenSSL-Win64\bin>
Could some one help me on this.?
Note : I was following this post
Powershell doesn't include current directory as a part of search path. The error message actually tells you this and explains what to do (emphasis added):
Suggestion [3,General]: The command openssl was not found, but does
exist in the current location. Windows PowerShell does not load
commands from the current location by default. If you trust this
command, instead type ".\openssl". See "get-help
about_Command_Precedence" for more details.

Password promt not displayed in PowerShell ISE

I have an executable from the android SDK: keytool.exe
I call it as following:
keytool.exe -list -keystore mykeystore.ks
When executed in cmd, the executable promts for the keystore password.
When executed in PowerShell ISE - nothing happens.
Why is the password promt not displayed inside powershell?
Looks like the powershell ISE does not support user promt (see the comments). Its a pitty, since it could have been a really good tool

unable to generate a keystore from an existing certificate file

I've lost my keystore file that was used to make release build for an android app. But I've the certificate file. Now I want to generate a new keystore from this existing certificate file but I'm unable to do that because I've forgot the alias name that was set when the keystore was created for the first time. Is there a way that I can use the same certificate file and generate a new keystore ? I have tried the following command but it didn't work.
keytool -import -alias foo -file certfile.cer -keystore publicKey.store
Does this link help ?
Generate a keystore using following command:
keytool -genkey -alias tomcat -keyalg RSA -keystore keystore.jks
Import CER file in java keystore:
keytool -importcert -file certificate.cer -keystore keystore.jks -alias "Alias"