我试图使用PowerShell在远程服务器上运行.cmd文件.
在我的.ps1脚本中我试过这个:
C:\MyDirectory\MyCommand.cmd
它导致此错误:
C:\MyDirectory\MyCommand.cmd is not recognized as the name of a cmdlet, function, script file, or operable program.
还有这个
Invoke-Command C:\MyDirectory\MyCommand.cmd
导致此错误:
Invoke-Command : Parameter set cannot be resolved using the specified named parameters.
我不需要将任何参数传递给PowerShell脚本.我正在寻找的正确语法是什么?
Invoke-Item
将查找文件类型的默认处理程序并告诉它运行它.
它与在资源管理器中双击文件或使用相同基本相同start.exe
.
尝试调用cmd /c C:\MyDirectory\MyCommand.cmd
- 这应该工作.