enthuguy
enthuguy

Reputation: 415

Setup Jenkins running on Linux to execute PowerShell script

How do you setup Jenkins running on Linux to execute a PowerShell script on a remote Windows Server 2008 without password prompt.

Master Jenkins on Linux / Slave on Windows. Would this work?

Upvotes: 2

Views: 5561

Answers (2)

88weighed
88weighed

Reputation: 141

EDIT

A complete edit, since I couldn't get the previous answer working.

$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
  • Now use Jenkins to execute a shell:

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

This is how I got it working eventually.

Upvotes: 1

Martin Nyolt
Martin Nyolt

Reputation: 4650

Install an SSH server on the Windows server and use a public/private key pair for authentication. On Linux, you can then run

ssh -i <private key file> user@host "command"

to issue "command" on the server.

Upvotes: 1

Related Questions