簡體   English   中英

psexec命令以使用參數運行Powershell腳本

[英]Psexec command to run powershell script with parameters

我正在嘗試在TFS2017中的遠程計算機上使用psexec運行powershell腳本,因為出於安全目的使用以下腳本禁用了PowerShell遠程處理和/或WMI。 但是我還需要將一些參數傳遞給我的powershell腳本。我已經在環境的configure變量部分中定義了這些參數值。不確定如何將參數傳遞給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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM