使用MsiExec和Powershell远程安装Puppet for Windows

时间:2012-11-06 15:02:52

标签: powershell teamcity powershell-v2.0 puppet

我正在尝试使用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**

脚本执行模式切换也没有运气。

3 个答案:

答案 0 :(得分:1)

你是否尝试在powershell中使用wmi方法?

 $localcommand="\\$TargetServer"+"\root\cimv2:Win32_Product"

 $msi = [wmiclass]"$localcommand"
 $result=$msi.Install('Path to yourmsi\Yourmsi-1.0.0.msi', "quiet=true", $true)

适合我(在团队城市)。

答案 1 :(得分:1)

这是我通过GPO的方式。

Windows上的Puppet:

修改msi以包含Puppet服务器参数,以便您可以通过GPO分发它:

1 download puppet gpl client for windows, which is a msi file 2 install Orca from MS , it is ...
2 install Orca from MS , it is free
3 whith Orca, edit the Msi
4. go to the Property categ, you will see there the Puppet server value
5. edit and save
6. create the gpo to distribute it. Remember that computer soft installs on reboot.

答案 2 :(得分:0)

Invoke-command -computername %puppet.client.host% -ScriptBlock {Param($options) Start-Process -Wait -Passthru -FilePath "msiexec.exe $options" -ArgumentList "/i C:\Temp\puppet-3.0.0.msi PUPPET_MASTER_SERVER=%env.puppet.master% /l*v C:\Temp\puppet-3.0.0.log /qn"}