Skip to content

Instantly share code, notes, and snippets.

@MSIH
Created March 12, 2020 20:57
Show Gist options
  • Save MSIH/af11c595ea28bf0e6cf633124ae9a62b to your computer and use it in GitHub Desktop.
Save MSIH/af11c595ea28bf0e6cf633124ae9a62b to your computer and use it in GitHub Desktop.
Download the latest VS Code System install file
$url = "https://update.code.visualstudio.com/latest/win32-x64/stable"
$vsCodePath = "D:\Artifacts\Software\Base\Visual Studio Code\"
# the url is s redirect - get the url with filename
$request = Invoke-WebRequest -Uri $url -MaximumRedirection 0 -ErrorAction Ignore
$location = $request.Headers.Location
$location
# output path is paht to vs code folder plus the file name
$output = $vsCodePath + $location.SubString($location.LastIndexOf('/') + 1)
$output
if (!(Test-Path $output)) {
Invoke-WebRequest -Uri $url -OutFile $output
}
$start = Get-Date
$when = $start.ToString("yyyy-MM-dd-hh-mm-ss")
Copy-Item ("$vsCodePath" + "VSCodeSetup-x64.exe") ("$vsCodePath" + "VSCodeSetup-x64-$when.exe")
Copy-Item $output ("$vsCodePath" + "VSCodeSetup-x64.exe") -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment