Skip to content

Instantly share code, notes, and snippets.

@Tallmaris
Created April 17, 2014 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tallmaris/10984688 to your computer and use it in GitHub Desktop.
Save Tallmaris/10984688 to your computer and use it in GitHub Desktop.
Install Puppet
# Install Puppet
$MsiUrl = "https://downloads.puppetlabs.com/windows/puppet-3.5.1.msi"
$PuppetInstalled = $false
try {
$ErrorActionPreference = "Stop";
Get-Command puppet | Out-Null
$PuppetInstalled = $true
$PuppetVersion=&puppet "--version"
Write-Host "Puppet $PuppetVersion is installed. This process does not ensure the exact version or at least version specified, but only that puppet is installed. Exiting..."
Exit 0
} catch {
Write-Host "Puppet is not installed, continuing..."
}
if (!($PuppetInstalled)) {
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
if (! ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) {
Write-Host -ForegroundColor Red "You must run this script as an administrator."
Exit 1
}
# Install it - msiexec will download from the url
$install_args = @("/qn", "/norestart","/i", $MsiUrl)
Write-Host "Installing Puppet. Running msiexec.exe $install_args"
$process = Start-Process -FilePath msiexec.exe -ArgumentList $install_args -Wait -PassThru
if ($process.ExitCode -ne 0) {
Write-Host "Installer failed."
Exit 1
}
# Stop the service that it autostarts
Write-Host "Stopping Puppet service that is running by default..."
Start-Sleep -s 5
Stop-Service -Name puppet
Write-Host "Puppet successfully installed."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment