PowerShell/scripts/install-visual-studio-code.ps1

26 lines
643 B
PowerShell
Raw Normal View History

2024-10-01 15:11:03 +02:00
<#
2021-08-30 16:12:11 +02:00
.SYNOPSIS
2022-07-15 17:12:01 +02:00
Installs Visual Studio Code
2021-08-30 16:12:11 +02:00
.DESCRIPTION
2022-07-15 17:12:01 +02:00
This PowerShell script installs Visual Studio Code.
2021-08-30 16:12:11 +02:00
.EXAMPLE
2023-08-06 21:35:36 +02:00
PS> ./install-visual-studio-code.ps1
2022-07-15 17:12:01 +02:00
.LINK
https://github.com/fleschutz/PowerShell
2021-08-30 16:12:11 +02:00
.NOTES
2022-07-15 17:12:01 +02:00
Author: Markus Fleschutz | License: CC0
2021-08-30 16:12:11 +02:00
#>
try {
2022-07-15 17:12:01 +02:00
"Installing Visual Studio Code, please wait..."
2021-08-30 16:12:11 +02:00
2022-07-15 17:12:01 +02:00
& winget install --id Microsoft.VisualStudioCode --accept-package-agreements --accept-source-agreements
if ($lastExitCode -ne "0") { throw "'winget install' failed" }
2021-08-30 16:12:11 +02:00
2022-07-15 17:12:01 +02:00
"Visual Studio Code installed successfully."
exit 0 # success
} catch {
2022-09-11 11:57:15 +02:00
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2022-07-15 17:12:01 +02:00
exit 1
2023-08-06 21:35:36 +02:00
}