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

25 lines
635 B
PowerShell
Raw Normal View History

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
2022-07-15 17:12:01 +02:00
PS> ./install-visual-studio-code
.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
2022-09-11 11:57:15 +02:00
}