2

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?

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

2 Comments

How is this related to the question? You don't seem to execute a remote command on a Windows machine.
The eventual idea is to run the command on a remote Windows machine, which is possible with powershell. Now just trying to get Jenkins and Powershell to get to work on Linux.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.