【发布时间】:2016-09-15 10:51:49
【问题描述】:
如何设置在 Linux 上运行的 Jenkins 以在没有密码提示的情况下在远程 Windows Server 2008 上执行 PowerShell 脚本。
Linux 上的主 Jenkins / Windows 上的奴隶。这行得通吗?
【问题讨论】:
标签: powershell jenkins jenkins-plugins windows-server-2008
如何设置在 Linux 上运行的 Jenkins 以在没有密码提示的情况下在远程 Windows Server 2008 上执行 PowerShell 脚本。
Linux 上的主 Jenkins / Windows 上的奴隶。这行得通吗?
【问题讨论】:
标签: powershell jenkins jenkins-plugins windows-server-2008
在 Windows 服务器上安装 SSH 服务器并使用公钥/私钥对进行身份验证。在 Linux 上,您可以运行
ssh -i <private key file> user@host "command"
在服务器上发出“命令”。
【讨论】:
编辑
完整的编辑,因为我无法得到以前的答案。
$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
powershell -NonInteractive -ExecutionPolicy ByPass /path/to/your/local.ps1
这就是我最终得到它的方式。
【讨论】: