Need to connect to remote server and execute ps1 script using jenkins

I created a Jenkins job that needs to connect to a remote machine and execute a ps1 script.

$pw = convertto-securestring -AsPlainText -Force -String "4444"
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist "eeeee\eee",$pw
$sess = New-PSSession -ComputerName server1 -Credential $cred
Enter-PSSession $sess

Answers


Add the remote machine as a slave, then run your script from 'execute windows Batch command' or install Powershell plugin and 'Run powershell script'.

Links:

  1. Add windows slave: https://wiki.jenkins-ci.org/display/JENKINS/Step+by+step+guide+to+set+up+master+and+slave+machines
  2. Powershell plugin: https://wiki.jenkins-ci.org/display/JENKINS/PowerShell+Plugin

Looks like you may be better served with Invoke-Command than Enter-PSSession. https://technet.microsoft.com/en-us/library/hh849719.aspx

Something along the lines of:

Invoke-Command -Credential $creds -ComputerName $server -FilePath $scriptname -ArgumentList $arg1, $arg2

Need Your Help

Scikit grid search for KNN regression ValueError: Array contains NaN or infinity

python numpy scikit-learn

I am trying to implement grid search for selecting best parameters for KNN regression using Scikit learn.

Order by clause in MySQL is not working inside a foreach loop

mysql sql-order-by

I'm trying to get the profiles names which are assigned to a specific subcategory