4747
4848 https://github.com/PowerShell/vscode-powershell/blob/develop/scripts/Install-VSCode.ps1
4949
50+ . PARAMETER Architecture
51+ A validated string defining the bit version to download. Values can be either 64 or 32.
52+ If 64 is chosen and the OS Architecture does not match, then the x86 build will be
53+ downloaded instead. If parameter is not used, then 64-bit is used as default.
54+
5055. PARAMETER BuildEdition
5156 A validated string defining which build edition or "stream" to download - stable or
5257 insiders edition. If the parameter is not used, then stable is downloaded as default.
6267 When present, causes Visual Studio Code to be launched as soon as installation
6368 has finished.
6469
70+ . EXAMPLE
71+ Install-VSCode.ps1 -Architecture 32
72+
73+ Installs Visual Studio Code (32-bit) and the powershell extension.
6574. EXAMPLE
6675 Install-VSCode.ps1 -LaunchWhenDone
6776
68- Installs Visual Studio Code and the PowerShell extension and then launches
77+ Installs Visual Studio Code (64-bit) and the PowerShell extension and then launches
6978 the editor after installation completes.
7079
7180. EXAMPLE
7281 Install-VSCode.ps1 -AdditionalExtensions 'eamodio.gitlens', 'vscodevim.vim'
7382
74- Installs Visual Studio Code, the PowerShell extension, and additional
83+ Installs Visual Studio Code (64-bit) , the PowerShell extension, and additional
7584 extensions.
7685
7786. EXAMPLE
7887 Install-VSCode.ps1 -BuildEdition Insider -LaunchWhenDone
7988
80- Installs Visual Studio Code Insiders Edition and then launches the editor
89+ Installs Visual Studio Code Insiders Edition (64-bit) and then launches the editor
8190 after installation completes.
8291
8392. NOTES
105114#>
106115[CmdletBinding ()]
107116param (
117+ [parameter ()]
118+ [ValidateSet (, " 64" , " 32" )]
119+ [string ]$Architecture = " 64" ,
120+
108121 [parameter ()]
109122 [ValidateSet (" stable" , " insider" )]
110123 [string ]$BuildEdition = " stable" ,
@@ -117,25 +130,41 @@ param(
117130)
118131
119132if (! ($IsLinux -or $IsOSX )) {
133+ switch ($Architecture ) {
134+ " 64" {
135+ if ((Get-WmiObject - Class Win32_OperatingSystem).OSArchitecture -eq " 64-bit" ) {
136+ $codePath = $env: ProgramFiles
137+ $bitVersion = " win32-x64"
138+ }
139+ else {
140+ $codePath = ${env: ProgramFiles(x86)}
141+ $bitVersion = " win32"
142+ }
143+ break ;
144+ }
145+ " 32" {
146+ $codePath = ${env: ProgramFiles(x86)}
147+ $bitVersion = " win32"
148+ break ;
149+ }
150+ }
120151 switch ($BuildEdition ) {
121152 " Stable" {
122- $codeCmdPath = " C:\Program* \Microsoft VS Code\bin\code.cmd"
153+ $codeCmdPath = " $codePath \Microsoft VS Code\bin\code.cmd"
123154 break ;
124155 }
125156 " Insider" {
126- $codeCmdPath = " C:\Program* \Microsoft VS Code Insiders\bin\code-insiders.cmd"
157+ $codeCmdPath = " $codePath \Microsoft VS Code Insiders\bin\code-insiders.cmd"
127158 break ;
128159 }
129160 }
130-
131-
132161 try {
133162 $ProgressPreference = ' SilentlyContinue'
134163
135164 if (! (Test-Path $codeCmdPath )) {
136165 Write-Host " `n Downloading latest $ ( $BuildEdition ) Visual Studio Code..." - ForegroundColor Yellow
137166 Remove-Item - Force " $env: TEMP \vscode-$ ( $BuildEdition ) .exe" - ErrorAction SilentlyContinue
138- Invoke-WebRequest - Uri " https://vscode-update.azurewebsites.net/latest/win32-x64 /$ ( $BuildEdition ) " - OutFile " $env: TEMP \vscode-$ ( $BuildEdition ) .exe"
167+ Invoke-WebRequest - Uri " https://vscode-update.azurewebsites.net/latest/$ ( $bitVersion ) /$ ( $BuildEdition ) " - OutFile " $env: TEMP \vscode-$ ( $BuildEdition ) .exe"
139168
140169 Write-Host " `n Installing Visual Studio Code..." - ForegroundColor Yellow
141170 Start-Process - Wait " $env: TEMP \vscode-$ ( $BuildEdition ) .exe" - ArgumentList / silent, / mergetasks= ! runcode
0 commit comments