gpt4 book ai didi

powershell - Invoke-Item cmdlet 能否启动带参数的可执行文件?

转载 作者:行者123 更新时间:2023-12-04 19:20:56 24 4
gpt4 key购买 nike

我正在尝试使用 PowerShell 安装一些自定义 Windows 服务,但我一直无法运行 InstallUtil 而不会出现以下错误:

A positional parameter cannot be found that accepts argument ''



这是我运行的导致上述错误的内容:
Invoke-Command -ComputerName <remote machine> -ScriptBlock {Invoke-Item C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe "<path to service exe>"}

最佳答案

从文档:

The Invoke-Item cmdlet performs the default action on the specified item.



我不相信命令行参数可以与默认操作一起使用。

然而...

在此示例中,调用可执行文件不需要 invoke-item。
Invoke-Command -ComputerName <remote machine> -ScriptBlock { C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe "<path to service exe>"}

关于powershell - Invoke-Item cmdlet 能否启动带参数的可执行文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3568777/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com