Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Psexec命令运行带参数的powershell脚本_Powershell_Parameter Passing_Powershell 3.0_Psexec - Fatal编程技术网

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

Psexec命令运行带参数的powershell脚本,powershell,parameter-passing,powershell-3.0,psexec,Powershell,Parameter Passing,Powershell 3.0,Psexec,我正在尝试在TFS2017中的远程计算机上使用psexec运行powershell脚本,因为出于安全目的,已使用以下脚本禁用powershell远程处理和/或WMI。但我还需要将一些参数传递给我的powershell脚本。我已在环境的“配置变量”部分中定义了这些参数值。不确定如何将参数传递给psexec中的powershell脚本 psexec \\computername cmd /c "Powershell.exe D:\script.ps1 -arg $(arg) -arg2 $(arg2

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

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

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

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

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

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

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