Psexec 命令到 运行 带参数的 powershell 脚本

Psexec command to run powershell script with parameters

我正在尝试 运行 在 TFS2017 中的远程计算机上使用 psexec 的 powershell 脚本,因为 PowerShell 远程处理 and/or WMI 出于安全目的使用以下脚本被禁用。但是我还需要将一些参数传递给我的 powershell script.I 已经在 environment.Not 的配置变量部分定义了这些参数值,确定如何将参数传递给 psexec 中的 powershell 脚本。

psexec \computername cmd /c "Powershell.exe D:\script.ps1 -arg $(arg) -arg2 $(arg2) -arg3 $(arg3)" 

但这没有work.Any帮助,我们将不胜感激。

我用的是这样的。没什么不同,但是那里有一个旁路,我在脚本路径之前声明了 -file 。

 psexec \$computername /s cmd /c %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -file c:\path\script.ps1 -parameter1 $blah -parameter2 $blahblah