Skip to content

Instantly share code, notes, and snippets.

@savishy
Last active May 13, 2018 07:59
Show Gist options
  • Save savishy/5ea55e7258422b7455b6476609979d21 to your computer and use it in GitHub Desktop.
Save savishy/5ea55e7258422b7455b6476609979d21 to your computer and use it in GitHub Desktop.
Script to provision my Windows 10 machine

How to run

  1. Open Powershell as Administrator
  2. 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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment