This repository has been archived by the owner on Jan 25, 2018. It is now read-only.
forked from hashicorp/puppet-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
windows.ps1
47 lines (37 loc) · 1.5 KB
/
windows.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<#
.SYNOPSIS
Installs Puppet on this machine.
.DESCRIPTION
Downloads and installs the PuppetLabs Puppet MSI package.
This script requires administrative privileges.
You can run this script from an old-style cmd.exe prompt using the
following:
powershell.exe -ExecutionPolicy Unrestricted -NoExit -File "windows.ps1"
.PARAMETER MsiUrl
This is the URL to the Puppet MSI file you want to install. This defaults
to a version from PuppetLabs.
#>
Param([string]$MsiUrl = "http://puppetlabs.com/downloads/windows/puppet-3.0.1.msi")
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
if (-not $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host -ForegroundColor Red "You must run this script as an administrator."
Exit 1
}
# Download Puppet
Write-Host "Downloading Puppet..."
$downloadPath = [IO.Path]::GetTempFileName()
$webClient = New-Object System.Net.WebClient
$webClient.DownloadFile($MsiUrl, $downloadPath)
# Install it
Write-Host "Installing Puppet..."
$install_args = @("/i", $downloadPath, "/qn", "/norestart")
$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."