0

remotePSExecuter.ps1 file:

$InputArgs=$args[0]
$Username=$args[1]
$Password=$args[2]
$ComputerName=$args[3]
$PSToExecute=$args[4]
write-host $Username $Password $ComputerName $PSToExecute
$SecurePassWord = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object -TypeName "System.Management.Automation.PSCredential" $Username, $SecurePassWord
$Session = New-PSSession -ComputerName $ComputerName -credential $Cred
$DownloadInstallJob = Invoke-Command -Session $Session -filepath "${PSToExecute}" -ArgumentList "${InputArgs}"
echo $DownloadInstallJob
Remove-PSSession -Session $Session

downloadInstallWinVcops.ps1 file:

$buildId=$args[0]
$storageDir = "C:\vcops-downloads"
$webclient = New-Object System.Net.WebClient
$url = "http://build-squid.com/build/mts/release/${buildId}/publish/Web_Installers/InstData/Windows/VM/file.exe"
write-host url=$url
write-host downloading windows vcops build ${buildId} ...
$file = "$storageDir\winvcops.exe"
$webclient.DownloadFile($url,$file)
write-host downloading windows vcops finished!
write-host installing windows vcops...
Start-Process -FilePath "C:\vcops-downloads\winvcops.exe" -ArgumentList "-i silent" -wait
write-host windows vcops installation finished!

This is the way I am calling on Jenkins machine:

.\EnterpriseAdapters/remotePSExecuter.ps1 sb-xxxx Administrator password 10.xx.xx.xx EnterpriseAdapters/downloadInstallWinVcops.ps1

Problem: Start-Process -FilePath "C:\vcops-downloads\winvcops.exe" -ArgumentList "-i silent" -wait is not getting called on remote machine.

Akhil
  • 479
  • 3
  • 13
Shashi Ranjan
  • 1,491
  • 6
  • 27
  • 52
  • Try using the absolute file-path and check the result. – Akhil Sep 25 '14 at 13:42
  • Download is working fine on remote machine. – Shashi Ranjan Sep 25 '14 at 14:12
  • The problem here is I think is "Start-Process" command is not executing on remote machine. – Shashi Ranjan Sep 25 '14 at 14:15
  • Did you try with the absolute file-path? – Akhil Sep 25 '14 at 14:27
  • Yes I tried that also. – Shashi Ranjan Sep 25 '14 at 14:37
  • .\EnterpriseAdapters/remotePSExecuter.ps1 sb-xxxx Administrator password 10.xx.xx.xx Administrator password C:/JenkinsWorkspace/setupAdapterEnv_SingleSliceWin/EnterpriseAdapters/downloadInstallWinVcops.ps1 – Shashi Ranjan Sep 25 '14 at 14:38
  • You missed specifying full path for EnterpriseAdapters/remotePSExecuter.ps1 . Try this once, if still it doesn't work, please post the console log on your jenkins build. – Akhil Sep 25 '14 at 14:49
  • That too did't worked. Jenkins log: Administrator password 10.xx.xx.xx C:\JenkinsWorkspace\setupAdapterEnv_SingleSliceWin\EnterpriseAdapters\downloadInstallWinVcops.ps1 url=http://build-squid.com/build/mts/release/sb-xxxx/publish/Web_Installers/InstData/Windows/VM/file.exe downloading windows vcops build sb-xxxx ... downloading windows vcops finished! installing windows vcops... windows vcops installation finished! Finished: SUCCESS – Shashi Ranjan Sep 25 '14 at 15:00
  • Hey Akhil, Do you know any other command which can install my exe silently? Which can be used there. – Shashi Ranjan Sep 25 '14 at 15:08
  • 1
    It's not clear how you've come to the conclusion it is not running the Start-Process command. Is there some output or log file you are checking? There is an open bug with the [-Wait parameter in remote sessions.](https://connect.microsoft.com/PowerShell/feedback/details/774903/powershell-3-0-start-process-disregards-wait-parameter-when-invoked-remotely) Also, is it possible you are running into a double hop issue? In the default authentication mechanism, credentials are not flowed to the remote session so your ability to connect to other systems is restricted. – Mike Zboray Sep 26 '14 at 08:12
  • related: https://stackoverflow.com/questions/49025062/windows-start-command-not-working-from-jenkins-pipeline short explanation if the problem is the same: Jenkins is running as a windows service and as such it cannot create a new console window – Florian Castellane Jul 06 '18 at 10:02

0 Answers0