remotePSExecuter.ps1 文件:
$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
下载InstallWinVcops.ps1文件:
$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!
这是我在 Jenkins 机器上调用的方式:
.\EnterpriseAdapters/remotePSExecuter.ps1 sb-xxxx Administrator password 10.xx.xx.xx EnterpriseAdapters/downloadInstallWinVcops.ps1
问题:
Start-Process -FilePath "C:\vcops-downloads\winvcops.exe" -ArgumentList "-i silent" -wait
没有在远程机器上被调用。