I automate most of my application installs so I can easily install on Windows Virtual Desktop (WVD), Virtual Desktop Infrastructure (VDI), or individual Azure Virtual machines. The code downloads the latest Microsoft Code build and installs the version with minimal PowerShell specific customizations (that I have discovered so far).
This script can be executed from a local directory or a unc path.
$url = "https://aka.ms/win32-x64-user-stable"
$install_args = '/verysilent /suppressmsgboxes /mergetasks=!runcode'
## Get install location UNC or Local
$sCurDir= "$((Get-Item -path $($(get-location).Path)).FullName)"
# get latest download url for Visual Studio Code
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$webRequest = [net.WebRequest]::Create("$url")
$asset = $webrequest.GetResponse()
$uri = $asset.ResponseUri.AbsoluteUri
$installer = "$sCurDir\$($uri.Split('/')[-1])"
# download installer
if (!(Test-Path $installer))
{
#$webClient = New-Object System.Net.WebClient
#$Webclient.DownloadFile("$($uri)", "$($installer)")
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $uri -OutFile $installer
}
# run installer
Start-Process -FilePath $installer -ArgumentList $install_args -Wait
#Customizations
CD "C:\Users\noyard\AppData\Local\Programs\Microsoft VS Code\"
code --install-extension ms-vscode.powershell --force
code --install-extension vscode-icons-team.vscode-icons --force
[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12
Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber
$PoSHSettingJSONfile="$($env:APPDATA)\Code\User\settings.json"
$PoSHSettingJSON=@"
{
//"powershell.powerShellDefaultVersion": "Windows PowerShell (x64)",
"editor.renderWhitespace": "all",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"path": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
}
},
"terminal.integrated.automationShell.linux": ""
}
"@
Set-Content -Path $PoSHSettingJSONfile -Value $PoSHSettingJSON
You must log in to post a comment.