4

I have an environment formed by a Jenkins Server, a couple of Jenkins Slaves (windows) and several remote windows computers all part of the same domain.

I need to run a jenkins job, which executes a powershell snippet consisted of several functions (part of a custom modules loaded on the Jenkins Slave) against other windows remote computers in the same domain (which do not have the modules installed).

These modules needs to run under a specific domain account with permissions to access the remote computers.

If I logon with on any of the jenkins slave (with that specific domain account) everything works fine.

By default, Jenkins executes the job on the slave using the NT authority\system account which, of course, returns me denied access errors.

Question: is there a way to tell Jenkins to execute the Job on the windows slave with another specific Domain Account and not the NT Authority\System one?

Tried already:

  • Invoke-command using credentials: this is not an option since the remote computers do not have the modules

  • Impersonation: tried a couple of functions found on the PS gallery but do not work

1
  • 1
    Hi, did you manage to solve this issue? I am looking at something similar. Commented Feb 19, 2020 at 9:39

1 Answer 1

2

You can run powershell as a process in a script and call that from Jenkins. In the script also you can use like:

$username = 'username'
$password = 'password'
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential $username,$securePassword

Start-Process Powershell.exe -Credential $credential

Hope it helps.

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

1 Comment

The problem is that I can't save the credentials in clear text a in a .ps1 file. Also, If I run powershell like that I won't be able to take advantage of that specific authenticated session from jenkins. Hope it makes sense.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.