Microsoft Visual Studio Code is becoming a very popular replacement for the regular PowerShell ISE. In this post you’ll get the script to automatically download and install Microsoft Visual Studio Code unattended.
The script below will check if $PackageName exists, and if it doesn’t it will automatically download the Visual Studio Code setup file from the $URL specified.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
Write-Verbose "Setting Arguments" -Verbose $StartDTM = (Get-Date) $Vendor = "Microsoft" $Product = "Visual Studio Code" $Version = "1.23.3" $PackageName = "VSCode_x64" $InstallerType = "exe" $Source = "$PackageName" + "." + "$InstallerType" $LogPS = "${env:SystemRoot}" + "\Temp\$Vendor $Product $Version PS Wrapper.log" $LogApp = "${env:SystemRoot}" + "\Temp\$PackageName.log" $Destination = "${env:ChocoRepository}" + "\$Vendor\$Product\$Version\$packageName.$installerType" $UnattendedArgs = '/verysilent /suppressmsgboxes /mergetasks=!runcode' $url = "https://aka.ms/win32-x64-user-stable" $ProgressPreference = 'SilentlyContinue' Start-Transcript $LogPS if( -Not (Test-Path -Path $Version ) ) { New-Item -ItemType directory -Path $Version } CD $Version Write-Verbose "Downloading $Vendor $Product $Version" -Verbose If (!(Test-Path -Path $Source)) { Invoke-WebRequest -Uri $url -OutFile $Source } Else { Write-Verbose "File exists. Skipping Download." -Verbose } Write-Verbose "Starting Installation of $Vendor $Product $Version" -Verbose (Start-Process "$PackageName.$InstallerType" $UnattendedArgs -Wait -Passthru).ExitCode Write-Verbose "Customization" -Verbose CD "C:\Program Files\Microsoft VS Code" code --install-extension ms-vscode.powershell -force Write-Verbose "Stop logging" -Verbose $EndDTM = (Get-Date) Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalSeconds) Seconds" -Verbose Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalMinutes) Minutes" -Verbose Stop-Transcript |
You might find the following blog posts helpful:
Hei Trond Eirik!
ser du fortsatt lever livet, forhåpentligvis tjener penger, og nyter 🙂 Etter nå snart 2 å som fast ansatt i Equinor, gjør jeg det samme, og plutselig fikk jeg endelig jobbet faktisk helt sammen emd Tore Willmar 🙂
Så får vi blitt litt skitne på hendene igjen… 🙂 Det går i Citrix, SCCM, Intune, modern management og frustrasjon over ting som går tregere enn ønsket 🙂
Skulle gjerne hatt en prat en dag du har tid? 🙂
Supert, jeg pinger deg på Twitter.