首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Powershell命令certUtil ssh和exitCode

Powershell命令certUtil ssh和exitCode
EN

Stack Overflow用户
提问于 2021-10-25 12:27:13
回答 1查看 757关注 0票数 0

我对powershell命令有问题:

代码语言:javascript
复制
powershell -command "& { ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=2 server@server -x -p 22 CertUtil -hashfile program.jar MD5 }"

我得到了这样的回应:

代码语言:javascript
复制
CertUtil: -hashfile command FAILED: 0x80070002 (WIN32: 2 ERROR_FILE_NOT_FOUND)
CertUtil: The system cannot find the file specified.

这就是我想要的回应。但这不是错误代码。这是一条输出消息。LastExitCode是'0‘。我需要一个真正的错误代码,而不分析输出消息。我试图操纵这个命令,但没有成功。我不明白为什么生成的错误不会在Powershell中抛出真正的错误。

EN

回答 1

Stack Overflow用户

发布于 2021-10-25 13:27:31

如果我使用这个命令(使用执行策略),我就会得到一个非'0‘的退出代码。这可能是goot的解决方案,即使我不确定原因。非常感谢你的帮助。

代码语言:javascript
复制
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.

1
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69708052

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档