使用 powershell 触发 exe,同时提供参数和自动输入
我们希望能够自动创建证书,以简化客户的流程。
为此,我们想要创建一个 powershell 脚本,该脚本运行 openssl 命令并自动填充输入。
下面是将运行的命令示例
openssl req -new -out client.csr -key client.key
这是脚本中的格式($loc 是 openssl.exe 的文件位置)
& $loc'\openssl.exe' @('req','-new','-out','client.csr','-key', 'client.key')
运行此命令会询问用户进行多个输入,我希望由脚本处理。
我们尝试在命令前添加 "input" |
和 回显输入 |
按照其他中的建议posts,以及不同格式的命令,但无济于事。
我发现这个脚本提供输入作为配置文件,但在测试时它要求输入无论如何
我是 powershell 的新手,所以如果我犯了一个愚蠢的错误:)
We're hoping to automate the creation of certificates to simplify the process for clients.
To do this, we wanted to create a powershell script that runs through the openssl commands and autofills the inputs.
Here's an example of a command that will be run
openssl req -new -out client.csr -key client.key
And here's the format within the script ($loc being openssl.exe's file location)
& $loc'\openssl.exe' @('req','-new','-out','client.csr','-key', 'client.key')
Running this command will ask the user for several inputs, which I would like to be handled by the script.
We've tried prepending the command with "input" |
and echo input |
as suggested in other posts, along with different formatting of the command, but to no avail.
I found this script that feeds the inputs as a configuration file, but in testing it asked for inputs anyway
I'm new to powershell, so please be gentle if I'm making a dumb mistake :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论