2016-09-15 120 views

回答

1

在Windows服務器上安裝SSH服務器,並使用公鑰/私鑰對進行身份驗證。在Linux上,您可以運行

ssh -i <private key file> [email protected] "command" 

在服務器上發出「命令」。

1

編輯

完整的編輯,因爲我無法得到以前的答案工作。

$username = "username" 
$secpass = ConvertTo-SecureString "password" -AsPlainText -Force 
$mycreds = New-Object System.Management.Automation.PSCredential ($username,$secpass) 
$remotepath = "c:\path\to\your.ps1" 

Invoke-Command -ComputerName windowscomputer -Credential $mycreds -FilePath $remotepath 
  • 現在使用詹金斯執行一個shell:

powershell -NonInteractive -ExecutionPolicy ByPass /path/to/your/local.ps1

這是我得到了它最終的工作。

+0

這與這個問題有什麼關係?你似乎沒有在Windows機器上執行遠程命令。 –

+0

最終的想法是在遠程Windows機器上運行該命令,這可以通過powershell來實現。現在只是想讓Jenkins和Powershell開始在Linux上工作。 – 88weighed