[Cmdletbinding()]
Param (
# Command to execute against the wrapper
[Parameter(Mandatory = $True)]
[String]$Bucket
)
$ErrorActionPrefrence = "Stop";
$Key = "puppet-agent-5.5.0-x64.msi"
$Path = "C:\Installers";
$ErrorActionPrefrence = "Stop";
New-Item -Type Directory $Path -ErrorAction SilentlyContinue
try {
# download Puppet agent from bucket
Write-Host "Downloading Puppet Agent" -ForegroundColor Green;
"Copy-Item resources/puppet-agent-5.5.0-x64.msi -Destination C:\Installers\puppet-agent-5.5.0-x64.msi"
# gsutil cp gs://$Bucket/$Key $Path\$Key
Write-Host "Downloaded $Object" -ForegroundColor Green;
}
catch {
$_.Exception.Message ;
}
try {
# install Puppet agent
Write-Host "Installing Puppet Agent" -ForegroundColor Green;
Invoke-Expression "cmd.exe /C start /wait msiexec /i '$Path\$Key' /qn PUPPET_AGENT_STARTUP_MODE=Disabled /L* 'C:\Windows\Temp\PuppetInstall.log'";
}
catch {
throw $_.Exception.Message;
}
Remove-Item -Recurse -Force C:\ProgramData\PuppetLabs\code