- Open Powershell as Administrator
- Run
iwr -useb https://gist.githubusercontent.com/savishy/5ea55e7258422b7455b6476609979d21/raw/provisionWindows.ps1 | iex;
<# | |
References: | |
- Check whether running as admin: https://stackoverflow.com/a/29129883 | |
#> | |
Set-ExecutionPolicy Bypass -Scope Process -Force; | |
$ErrorActionPreference = "Stop" | |
$packageList = @{ | |
powershell = "" | |
dropbox = "" | |
vagrant = "2.1.1" | |
virtualbox = "5.2.12" | |
adobereader = "" | |
winrar = "" | |
vlc = "" | |
git = "" | |
atom = "" | |
} | |
function failIfNotAdministrator() { | |
$elevated = ([Security.Principal.WindowsPrincipal] ` | |
[Security.Principal.WindowsIdentity]::GetCurrent() | |
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) | |
if (!$elevated) { | |
Write-Error "This script needs to be run as administrator." | |
} | |
} | |
function installChoco() { | |
# Install Choco | |
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) | |
} | |
#### MAIN #### | |
failIfNotAdministrator | |
installChoco | |
$packageList.Keys | % { | |
$packageName = $_ | |
$packageVersion = $packageList.Item($packageName) | |
$chocoCmd = "choco install -y $packageName" | |
if ($packageVersion.Trim()) { | |
$chocoCmd += " --version=$packageVersion" | |
} | |
Write-Host $chocoCmd | |
iex $chocoCmd | |
} |