2012-11-06 169 views
1

我想使用Team City和PowerShell內嵌腳本遠程安裝Puppet Client for Windows。使用MsiExec和Powershell遠程安裝Puppet

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** 

沒有好的腳本執行模式切換。

回答

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) 

適用於我(團隊城市)。

+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「} – Maverick

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"} 
1

這是我通過GPO完成的。在Windows

木偶:

修改微星包括木偶服務器PARAM所以您可以通過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.