我对powershell命令有问题:
powershell -command "& { ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=2 server@server -x -p 22 CertUtil -hashfile program.jar MD5 }"我得到了这样的回应:
CertUtil: -hashfile command FAILED: 0x80070002 (WIN32: 2 ERROR_FILE_NOT_FOUND)
CertUtil: The system cannot find the file specified.这就是我想要的回应。但这不是错误代码。这是一条输出消息。LastExitCode是'0‘。我需要一个真正的错误代码,而不分析输出消息。我试图操纵这个命令,但没有成功。我不明白为什么生成的错误不会在Powershell中抛出真正的错误。
发布于 2021-10-25 13:27:31
如果我使用这个命令(使用执行策略),我就会得到一个非'0‘的退出代码。这可能是goot的解决方案,即使我不确定原因。非常感谢你的帮助。
powershell -ExecutionPolicy Bypass -Command "& ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=2 server\server -x -p 22 CertUtil -hashfile program.jar MD5"; echo $LASTEXITCODE
CertUtil: -hashfile command FAILED: 0x80070002 (WIN32: 2 ERROR_FILE_NOT_FOUND)
CertUtil: The system cannot find the file specified.
1https://stackoverflow.com/questions/69708052
复制相似问题