-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNew-DevMachine.ps1
More file actions
281 lines (267 loc) · 12.9 KB
/
Copy pathNew-DevMachine.ps1
File metadata and controls
281 lines (267 loc) · 12.9 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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<#
.SYNOPSIS
Sets up a new developer machine with mainstream tools and optional extras.
.DESCRIPTION
Installs .NET SDK, PowerShell, Visual Studio, VS Code, SQL Server Developer Edition by default.
Also installs Ollama, Microsoft Scout Agent, and Microsoft 365 Copilot by default for local AI
model/runtime support and pulls Phi-4.
JavaScript/Node.js and Python are strongly optional and are only installed when explicitly requested.
Optionally installs Power Platform tools and non-mainstream .NET SDKs.
.PARAMETER InstallNode
Installs Node.js and JavaScript tooling if set to $true.
.PARAMETER InstallPython
Installs Python if set to $true.
.PARAMETER InstallPowerPlatform
Installs Power Platform CLI/tools if set to $true.
.PARAMETER InstallDotNetExtras
Installs non-mainstream .NET SDKs if set to $true.
.PARAMETER GitUserName
Sets git config --global user.name to this value if provided.
.PARAMETER GitUserEmail
Sets git config --global user.email to this value if provided.
.EXAMPLE
.\New-DevMachine.ps1 -InstallNode $true -InstallPython $false -GitUserName "Your Name" -GitUserEmail "you@example.com"
#>
param(
[bool]$InstallNode = $false,
[bool]$InstallPython = $false,
[bool]$InstallPowerPlatform = $false,
[bool]$InstallDotNetExtras = $false,
[string]$GitUserName = "",
[string]$GitUserEmail = ""
)
####################################################################################
Set-ExecutionPolicy Unrestricted -Scope Process -Force
$VerbosePreference = 'SilentlyContinue' # 'SilentlyContinue' # 'Continue'
if ($MyInvocation.MyCommand.Path) {
[String]$ThisScript = $MyInvocation.MyCommand.Path
} else {
[String]$ThisScript = (Get-Location).Path
}
[String]$ThisDir = Split-Path $ThisScript
Set-Location $ThisDir # Ensure our location is correct, so we can use relative paths
Write-Host "*****************************"
Write-Host "*** Starting: $ThisScript On: $(Get-Date)"
Write-Host "*****************************"
####################################################################################
Write-Host "Starting developer machine setup..." -ForegroundColor Cyan
# General Developer Experience
Write-Host "\n==============================="
Write-Host "Installing PowerShell..." -ForegroundColor Yellow
Write-Host "===============================\n"
if (-not (Get-Command pwsh -ErrorAction SilentlyContinue)) {
winget install --id Microsoft.PowerShell --silent
} else {
Write-Host "PowerShell already installed." -ForegroundColor DarkGray
}
if (-not (Get-Command wt -ErrorAction SilentlyContinue)) {
winget install --id Microsoft.WindowsTerminal --silent
} else {
Write-Host "Windows Terminal already installed." -ForegroundColor DarkGray
}
if (-not (Get-Command powertoys -ErrorAction SilentlyContinue)) {
winget install --id Microsoft.PowerToys --source winget
} else {
Write-Host "PowerToys already installed." -ForegroundColor DarkGray
}
if (-not (Get-Command "StorageExplorer" -ErrorAction SilentlyContinue)) {
winget install --id Microsoft.Azure.StorageExplorer -e
} else {
Write-Host "Azure Storage Explorer already installed." -ForegroundColor DarkGray
}
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
winget install --id Git.Git --silent
} else {
Write-Host "Git already installed." -ForegroundColor DarkGray
}
if ($GitUserName) {
git config --global user.name $GitUserName
}
if ($GitUserEmail) {
git config --global user.email $GitUserEmail
}
if (-not (Get-Command gh -ErrorAction SilentlyContinue)) {
winget install --id GitHub.cli --silent
} else {
Write-Host "GitHub CLI already installed." -ForegroundColor DarkGray
}
if (-not (Get-Command "PaintDotNet" -ErrorAction SilentlyContinue)) {
winget install Paint.NET --silent
} else {
Write-Host "Paint.NET already installed." -ForegroundColor DarkGray
}
try {
if (-not (wsl -l -q | Select-String -Pattern "Ubuntu")) {
wsl --install
if ($LASTEXITCODE -ne 0) {
Write-Host "WSL installation failed or is corrupted. Please repair WSL manually and re-run this script." -ForegroundColor Red
}
} else {
Write-Host "WSL already installed." -ForegroundColor DarkGray
}
} catch {
Write-Host "WSL installation encountered an error: $_.Exception.Message. Please repair WSL manually and re-run this script." -ForegroundColor Red
}
# Azure Developer Experience
Write-Host "\n==============================="
Write-Host "Installing Azure tooling..." -ForegroundColor Yellow
Write-Host "===============================\n"
if (-not (Get-Command az -ErrorAction SilentlyContinue)) {
winget install Microsoft.AzureCLI --silent
} else {
Write-Host "Azure CLI already installed." -ForegroundColor DarkGray
}
if (-not (Get-Command bicep -ErrorAction SilentlyContinue)) {
winget install -e --id Microsoft.Bicep --silent
} else {
Write-Host "Azure Bicep CLI already installed." -ForegroundColor DarkGray
}
# .NET Developer Experience
Write-Host "\n==============================="
Write-Host "Installing .NET developer experience..." -ForegroundColor Yellow
Write-Host "===============================\n"
if (-not (Get-Command dotnet -ErrorAction SilentlyContinue)) {
winget install --id Microsoft.DotNet.SDK.10 --silent
$env:PATH = [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::Machine) + ";" + [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User)
if (-not (Get-Command dotnet -ErrorAction SilentlyContinue)) {
Write-Host "dotnet still not found after install. Please restart your shell and re-run this script to complete .NET setup." -ForegroundColor Red
} else {
if (-not (dotnet tool list -g | Select-String -Pattern "dotnet-ef")) {
dotnet tool install --global dotnet-ef
} else {
Write-Host "dotnet-ef tool already installed." -ForegroundColor DarkGray
}
}
} else {
Write-Host ".NET SDK already installed." -ForegroundColor DarkGray
if (-not (dotnet tool list -g | Select-String -Pattern "dotnet-ef")) {
dotnet tool install --global dotnet-ef
} else {
Write-Host "dotnet-ef tool already installed." -ForegroundColor DarkGray
}
}
dotnet dev-certs https --trust
if (-not (Get-Command devenv -ErrorAction SilentlyContinue)) {
winget install --id Microsoft.VisualStudio.Community --override "--quiet --add Microsoft.Visualstudio.Workload.Azure --add Microsoft.VisualStudio.Workload.Data --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb"
} else {
Write-Host "Visual Studio already installed." -ForegroundColor DarkGray
}
if (-not (Get-Command code -ErrorAction SilentlyContinue)) {
winget install --id Microsoft.VisualStudioCode --exact --silent --accept-package-agreements --accept-source-agreements
$env:PATH = [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::Machine) + ";" + [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User)
if (-not (Get-Command code -ErrorAction SilentlyContinue)) {
Write-Host "VS Code still not found after install. Please restart your shell and re-run this script to complete VS Code setup and extension installation." -ForegroundColor Red
}
}
if (Get-Command code -ErrorAction SilentlyContinue) {
# Critical: C# (csharp), SQL Project, SSMS (mssql), Bicep, YAML (redhat), PowerShell. DBCode and redhat.vscode-yaml are the only non-Microsoft exceptions kept.
$extensions = @(
"ms-dotnettools.csharp",
"ms-dotnettools.vscodeintellicode-csharp",
"ms-vscode.hexeditor",
"ms-vscode.powershell",
"ms-vscode.copilot-mermaid-diagram",
"ms-vscode-remote.remote-wsl",
"redhat.vscode-yaml",
"ms-azuretools.vscode-bicep",
"ms-azuretools.vscode-azureresourcegroups",
"ms-azuretools.vscode-azure-github-copilot",
"GitHub.copilot",
"GitHub.copilot-chat",
"ms-windows-ai-studio.windows-ai-studio",
"ms-mssql.mssql",
"ms-mssql.sql-database-projects-vscode",
"DBCode.dbcode"
)
foreach ($ext in $extensions) {
if (-not (code --list-extensions | Select-String -Pattern "^$ext$")) {
Write-Host "\n--- Installing VS Code extension: $ext ---\n" -ForegroundColor Green
code --install-extension $ext
} else {
Write-Host "VS Code extension $ext already installed." -ForegroundColor DarkGray
}
}
} else {
Write-Host "VS Code command not found. Please restart your shell and re-run this script to install extensions." -ForegroundColor Red
}
if (-not (Get-Command sqlservr -ErrorAction SilentlyContinue)) {
Write-Host "\n--- Installing SQL Server Developer Edition ---\n" -ForegroundColor Yellow
winget install Microsoft.SQLServer.2022.Developer -e --override "/Q /IACCEPTSQLSERVERLICENSETERMS /ACTION=Install /ENU"
if ($LASTEXITCODE -ne 0) {
Write-Host "SQL Server installation did not complete successfully (exit code $LASTEXITCODE). You may need to retry or install manually." -ForegroundColor Red
} else {
Write-Host "SQL Server Developer installed using default instance settings." -ForegroundColor DarkGray
}
} else {
Write-Host "SQL Server Developer Edition already installed." -ForegroundColor DarkGray
}
if (-not (Get-Command func -ErrorAction SilentlyContinue)) {
Write-Host "\n--- Installing Azure Functions Core Tools ---\n" -ForegroundColor Yellow
winget install Microsoft.Azure.FunctionsCoreTools --silent
} else {
Write-Host "Azure Functions Core Tools already installed." -ForegroundColor DarkGray
}
if (-not (Get-Command ollama -ErrorAction SilentlyContinue)) {
Write-Host "\n--- Installing Ollama ---\n" -ForegroundColor Yellow
winget install --id Ollama.Ollama -e --silent
} else {
Write-Host "Ollama already installed." -ForegroundColor DarkGray
}
Write-Host "\n--- Installing Microsoft Scout Agent ---\n" -ForegroundColor Yellow
winget install --id Microsoft.ScoutAgent --exact --silent --accept-package-agreements --accept-source-agreements
Write-Host "\n--- Installing Microsoft 365 Copilot ---\n" -ForegroundColor Yellow
winget install --id Microsoft.365Copilot --exact --silent --accept-package-agreements --accept-source-agreements
$env:PATH = [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::Machine) + ";" + [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User)
if (-not (Get-Command ollama -ErrorAction SilentlyContinue)) {
Write-Host "Ollama command not found after install. Please open a new terminal window and run: ollama pull phi4" -ForegroundColor Red
} else {
$phi4Installed = $false
try {
$phi4Installed = [bool](ollama list 2>$null | Where-Object { $_ -match '^\s*phi4(?::\S+)?\s' })
} catch {
Write-Host "Unable to query existing Ollama models. Attempting to pull Phi-4 anyway..." -ForegroundColor Yellow
}
if (-not $phi4Installed) {
Write-Host "\n--- Pulling Phi-4 model in Ollama ---\n" -ForegroundColor Yellow
ollama pull phi4
if ($LASTEXITCODE -ne 0) {
Write-Host "Phi-4 pull failed. If this is a fresh install, open a new terminal window and re-run: ollama pull phi4" -ForegroundColor Red
}
} else {
Write-Host "Phi-4 already installed in Ollama." -ForegroundColor DarkGray
}
}
# Optional installations
if ($InstallNode) {
if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
Write-Host "\n--- Installing Node.js and JavaScript tooling ---\n" -ForegroundColor Green
winget install --id OpenJS.NodeJS --silent
# Optionally install npm, yarn, etc.
} else {
Write-Host "Node.js already installed." -ForegroundColor DarkGray
}
}
if ($InstallPython) {
if (-not (Get-Command python -ErrorAction SilentlyContinue)) {
Write-Host "\n--- Installing Python ---\n" -ForegroundColor Green
winget install --id Python.Python.3 --silent
} else {
Write-Host "Python already installed." -ForegroundColor DarkGray
}
}
if ($InstallPowerPlatform) {
if (-not (Get-Command pac -ErrorAction SilentlyContinue)) {
Write-Host "\n--- Installing Power Platform CLI ---\n" -ForegroundColor Green
winget install --id Microsoft.PowerPlatformCLI --silent
} else {
Write-Host "Power Platform CLI already installed." -ForegroundColor DarkGray
}
if (Get-Command code -ErrorAction SilentlyContinue) {
if (-not (code --list-extensions | Select-String -Pattern "^microsoft-IsvExpTools.powerplatform-vscode$")) {
code --install-extension microsoft-IsvExpTools.powerplatform-vscode
} else {
Write-Host "Power Platform VS Code extension already installed." -ForegroundColor DarkGray
}
}
}
Write-Host "Developer machine setup complete." -ForegroundColor Cyan