-
Notifications
You must be signed in to change notification settings - Fork 4
/
install.ps1
51 lines (41 loc) · 1.78 KB
/
install.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
48
49
50
51
$ErrorActionPreference = "Stop"
If (!([Security.Principal.WindowsPrincipal] `
[Security.Principal.WindowsIdentity]::GetCurrent()
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Error "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!"
}
Function Reset-Path {
$MachinePaths = [Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::Machine) -split ';'
$UserPaths = [Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::User) -split ';'
$Env:Path = ($MachinePaths + $UserPaths) -join ';'
}
Write-Host 'Bootstrapping Workup'
$WORKUP_VERSION = "0.1.6"
$WORKUP_URL = "https://github.com/cvent/workup/releases/download/v${WORKUP_VERSION}/workup.msi"
$WORKUP_DIR = Join-Path ${HOME} '.workup'
Get-WmiObject `
-Class Win32_Product `
-Filter "Name LIKE 'Workup%'" |% {
Write-Host -NoNewLine "Uninstalling Workup v$($_.Version)... "
$_.Uninstall() | Out-Null
Write-Host -ForegroundColor 'Green' 'OK'
}
If (!(Test-Path ${WORKUP_DIR} -PathType 'Container')) {
Write-Host -NoNewLine "Creating ~/.workup directory... "
New-Item -Type Directory ${WORKUP_DIR} | Out-Null
Write-Host -ForegroundColor 'Green' 'OK'
}
Write-Host -NoNewLine "Installing Workup v${WORKUP_VERSION}... "
$installer = Join-Path $WORKUP_DIR 'workup.msi'
(New-Object System.Net.WebClient).DownloadFile($WORKUP_URL, $installer)
cmd /c start '' /wait msiexec /i $installer /qn
Write-Host -ForegroundColor 'Green' 'OK'
Reset-Path
Write-Host -NoNewLine "Checking for workup command... "
If (Get-Command 'workup' -ErrorAction Ignore) {
Write-Host -ForegroundColor 'Green' 'OK'
} else {
Write-Host -ForegroundColor 'Red' 'Not found'
Exit 1
}
Write-Host 'You are ready to run workup'