This repository has been archived by the owner on May 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
3_Install_and_Configure_VS_Code.ps1
94 lines (79 loc) · 2.98 KB
/
3_Install_and_Configure_VS_Code.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#############################################
# 3. Install and Configure VS Code
# by Josh Cooper
#############################################
Write-Host "Installing and Configuring VS Code..." -ForegroundColor Black -BackgroundColor Yellow
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Host "You didn't run this script as an Administrator. This script will self elevate to run as an Administrator and continue."
$length = 5
for ($i = 1; $i -le $length; $i++) {
$j = $length - $i
Write-Host "Elevating in $j seconds..." -ForegroundColor white -BackgroundColor darkred
Start-Sleep 1
}
Write-Host #ends the line after loop
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs;
exit
}
#no errors throughout
$ErrorActionPreference = 'silentlycontinue'
$LogFolder = "C:\Temp\SetupScripts\VSCode"
If (Test-Path $LogFolder) {
Write-Output "$LogFolder exists. Skipping."
}
Else {
Write-Output "The folder '$LogFolder' doesn't exist. This folder will be used for storing logs created after the script runs. Creating now."
Start-Sleep 1
New-Item -Path "$LogFolder" -ItemType Directory
Write-Output "The folder $LogFolder was successfully created."
}
Start-Transcript -OutputDirectory "$LogFolder"
Function InstallVSCode {
choco install vscode -y
}
Function InstallVSCodeExt {
$extensions =
"akamud.vscode-theme-onedark",
"ms-dotnettools.csharp",
"streetsidesoftware.code-spell-checker",
"ms-azuretools.vscode-docker",
"eamodio.gitlens",
"techer.open-in-browser",
"esbenp.prettier-vscode",
"ms-python.python",
"ms-vscode-remote.remote-wsl",
"vscode-icons-team.vscode-icons",
"icrawl.discord-vscode",
"wholroyd.jinja",
"ritwickdey.liveserver",
"octref.vetur"
$cmd = "code --list-extensions"
Invoke-Expression $cmd -OutVariable output | Out-Null
$installed = $output -split "\s"
foreach ($ext in $extensions) {
if ($installed.Contains($ext)) {
Write-Host $ext "already installed." -ForegroundColor Gray
}
else {
Write-Host "Installing" $ext "..." -ForegroundColor White
code --install-extension $ext
}
}
}
function SettingsDotJson {
code
$folderPath = "C:\setup-windows10-main"
$inFile = "$folderPath\VSCode\settings.json"
$outFile = "$env:APPDATA\Code\User\settings.json"
Write-Host "Copying from $inFile to $outFile"
Copy-Item -Path $inFile -Destination $outFile
}
Write-Host "Installing VS Code..." -BackgroundColor Magenta -ForegroundColor White
InstallVSCode
Start-Sleep 1
Write-Host "Installing VS Code Extensions..." -BackgroundColor Magenta -ForegroundColor White
InstallVSCodeExt
Start-Sleep 1
Write-Host "Implement Custom Settings..." -BackgroundColor Magenta -ForegroundColor White
SettingsDotJson
Start-Sleep 1