-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall-windows.ps1
More file actions
executable file
·45 lines (36 loc) · 1.63 KB
/
install-windows.ps1
File metadata and controls
executable file
·45 lines (36 loc) · 1.63 KB
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
# NOTE: Must be running in an administrative prompt!
if ( ! ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
throw "Insufficient permissions to run this script. Open the PowerShell console as an administrator and run this script again."
}
if ( Get-ExecutionPolicy -eq "Restricted" ) {
throw "Insufficient execution policy to run this script. Set execution policy to Remote-Signed and run this script again."
}
if (! (Test-Path -Path "$home/.dotfilestoload")) {
throw "Before installation, please define all modules to be loaded in `$HOME/.dotfilestoload"
}
function Use-Dotfile() { # Expects one argument -- module name
Param(
[Parameter(Mandatory=$true)]
[string]$ModuleName
)
if (! (Test-Path -Path $Env:DOTFILESTOLOAD)) {
throw "Can't find `$DOTFILESTOLOAD file"
}
else {
$dotfilesContent = Get-Content -Path $Env:DOTFILESTOLOAD
return $dotfilesContent -contains $ModuleName # Needs a complete (but case-insensitive) match, so commented lines won't match
}
}
# Install Chocolatey
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
########################################
# Install packages
########################################
Install-Module oh-my-posh -Scope CurrentUser -Force
if (Use-Dotfile "git") {
choco install -y git
Install-Module posh-git -Scope CurrentUser -Force
}
if (Use-Dotfile "maven") {
choco install -y maven
}