How I install Microsoft Code

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 = ""
$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

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
 Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber

    //"powershell.powerShellDefaultVersion": "Windows PowerShell (x64)",
    "editor.renderWhitespace": "all",
    "": {
        "PowerShell": {
            "path": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
    "terminal.integrated.automationShell.linux": ""
Set-Content -Path $PoSHSettingJSONfile -Value $PoSHSettingJSON