我正在尝试使用 Team City 和 Powershell 内联脚本远程安装 Puppet Client for Windows。
Invoke-command –computername %Machine Host Name% –ScriptBlock {Param($options) Start-Process -FilePath "msiexec.exe $options" -ArgumentList "/i C:\Temp\puppet-3.0.0.msi PUPPET_MASTER_SERVER=%Puppet Master Server% /l*v C:\Temp\puppet-3.0.0.log /qn" -Wait –Passthru}
当我从本地机器执行时,它工作得很好,但似乎 TeamCity 在处理引号方面存在一些问题。
**[Step 2/2] Invoke-Command : A positional parameter cannot be found that accepts argument '
[09:08:08][Step 2/2] –ScriptBlock'.
[09:08:08][Step 2/2] At line:1 char:15
[09:08:08][Step 2/2] + Invoke-command <<<< –computername vavp-pmo-agt08 –ScriptBlock {Param($option
[09:08:08][Step 2/2] s) Start-Process -FilePath msiexec.exe $options -ArgumentList /i C:\Temp\puppet
[09:08:08][Step 2/2] -3.0.0.msi PUPPET_MASTER_SERVER=vavt-pmo-sbx23.company.com /l*v C:\Temp\puppet
[09:08:08][Step 2/2] -3.0.0.log /qn -Wait –Passthru}
[09:08:08][Step 2/2] + CategoryInfo : InvalidArgument: (:) [Invoke-Command], Parameter
[09:08:08][Step 2/2] BindingException
[09:08:08][Step 2/2] + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell
[09:08:08][Step 2/2] .Commands.InvokeCommandCommand
[09:08:08][Step 2/2]
[09:08:08][Step 2/2] Process exited with code 1**
脚本执行模式开关也没有运气。