-
Notifications
You must be signed in to change notification settings - Fork 0
/
Install-DeveloperWorkstationEntPro.ps1
147 lines (122 loc) · 5.46 KB
/
Install-DeveloperWorkstationEntPro.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
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
<#
.SYNOPSIS
This script installs applications and tools commonly used by professional developers on a fresh Windows installation.
.DESCRIPTION
The script installs Visual Studio Code, Azure CLI, Azure Data Studio, SQL Server Developer Edition, Google Chrome, Mozilla Firefox,
Microsoft Office, and other essential tools for development. It also provides the option to install Visual Studio 2022 Professional
or Enterprise edition based on user choice.
.NOTES
Script Name: Install-DeveloperWorkstationEntPro.ps1
Author: Tom Blanchard
Date: February 6 2024
#>
# Function to check for internet connection
function Test-InternetConnection {
$connected = $false
try {
$request = [System.Net.WebRequest]::Create("http://www.google.com")
$response = $request.GetResponse()
$connected = $response.StatusCode -eq "OK"
$response.Close()
} catch {
$connected = $false
}
return $connected
}
# Function to install applications
function Install-Application {
param (
[string]$AppName,
[string]$AppIdentifier
)
Write-Host "Installing $AppName"
# Run winget to install the application
$installResult = winget install $AppIdentifier
# Check if the installation result indicates that the product is already installed
if ($installResult.ExitCode -eq $null) {
Write-Host "$AppName is already installed"
}
# Check if the installation was successful
elseif ($installResult.ExitCode -eq 0) {
Write-Host "$AppName installed successfully"
} else {
Write-Warning "Failed to install $AppName. Exit code: $($installResult.ExitCode)"
# Display error log if available
if ($installResult.ErrorLog -ne $null) {
Write-Host "Error log for $($AppName):"
Write-Host $installResult.ErrorLog
}
}
}
# Function to prompt user for Visual Studio edition choice
function Prompt-VisualStudioEdition {
Write-Host "Which edition of Visual Studio do you want to install?"
Write-Host "1. Professional"
Write-Host "2. Enterprise"
$choice = Read-Host "Enter your choice (1 or 2)"
return $choice
}
# Check internet connection
if (-not (Test-InternetConnection)) {
Write-Host "No internet connection found. Please connect to the internet and try again."
exit
}
# Define download URLs
$professionalUrl = "https://aka.ms/vs/17/release/vs_professional.exe"
$enterpriseUrl = "https://aka.ms/vs/17/release/vs_enterprise.exe"
# Prompt user for Visual Studio edition choice
$vsEditionChoice = Prompt-VisualStudioEdition
# Download and run Visual Studio installer
if ($vsEditionChoice -eq "1") {
$installerUrl = $professionalUrl
} elseif ($vsEditionChoice -eq "2") {
$installerUrl = $enterpriseUrl
} else {
Write-Warning "Invalid choice. Please choose 1 for Professional or 2 for Enterprise."
exit
}
# Download installer
$downloadDirectory = [System.IO.Path]::Combine([System.Environment]::GetFolderPath('UserProfile'), 'Downloads')
$installerPath = Join-Path -Path $downloadDirectory -ChildPath "vs_installer.exe"
Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath
# Wait until the download is complete
$downloadComplete = $false
$previousFileSize = -1
$timeoutInSeconds = 300 # Adjust timeout as needed (e.g., 5 minutes)
$timeout = [System.DateTime]::Now.AddSeconds($timeoutInSeconds)
while (-not $downloadComplete -and [System.DateTime]::Now -lt $timeout) {
Start-Sleep -Seconds 5 # Check every 5 seconds
$currentFileSize = (Get-Item $installerPath).Length
if ($currentFileSize -eq $previousFileSize) {
$downloadComplete = $true
} else {
$previousFileSize = $currentFileSize
}
}
if ($downloadComplete) {
Write-Host "Download complete. Proceeding to install."
# Run installer with specified options
Start-Process -FilePath $installerPath -ArgumentList "--layout C:\VSLayout --lang en-US" -Wait
} else {
Write-Host "Download did not complete within the specified timeout. Aborting installation."
exit
}
# Install other applications
Write-Host "Installing other applications..."
Install-Application -AppName "VSCode" -AppIdentifier "Microsoft.VisualStudioCode"
Install-Application -AppName "Terminal" -AppIdentifier "Microsoft.WindowsTerminal"
Install-Application -AppName "AzureCLI" -AppIdentifier "Microsoft.AzureCLI"
Install-Application -AppName "DataCLI" -AppIdentifier "Microsoft.AzureDataCLI"
Install-Application -AppName "Azure StorageExplorer" -AppIdentifier "Microsoft.AzureStorageExplorer"
Install-Application -AppName "PowerBI" -AppIdentifier "Microsoft.PowerBI"
Install-Application -AppName "Powershell7" -AppIdentifier "Microsoft.PowerShell"
Install-Application -AppName "RDP" -AppIdentifier "Microsoft.RemoteDesktopClient"
Install-Application -AppName "OneDrive Enterprise" -AppIdentifier "Microsoft.OneDriveForBusiness"
Install-Application -AppName "Acrobat" -AppIdentifier "Adobe.Acrobat.Reader.64-bit"
Install-Application -AppName "Azure Data Studio" -AppIdentifier "Microsoft.AzureDataStudio"
Install-Application -AppName "SQL Server Management Studio" -AppIdentifier "Microsoft.SQLServerManagementStudio"
Install-Application -AppName "GitHub Desktop" -AppIdentifier "GitHub.GitHubDesktop"
# Update all installed packages using winget
Write-Host "Updating installed packages..."
winget update --all
Write-Host "END"