【问题标题】:Psexec command to run powershell script with parameterspsexec 命令运行带参数的 powershell 脚本
【发布时间】:2018-12-22 02:27:08
【问题描述】:

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

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

但这不起作用。任何帮助将不胜感激。

【问题讨论】:

    标签: powershell parameter-passing powershell-3.0 psexec


    【解决方案1】:

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

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

    【讨论】:

      最近更新 更多