Created
November 15, 2022 19:14
-
-
Save scuq/eee34c3f55a3f0417c1af1a1600faeba to your computer and use it in GitHub Desktop.
quick and dirty vscode update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-host "Disable Certificate checks" | |
Add-Type @" | |
using System; | |
using System.Net; | |
using System.Net.Security; | |
using System.Security.Cryptography.X509Certificates; | |
public class ServerCertificateValidationCallback | |
{ | |
public static void Ignore() | |
{ | |
ServicePointManager.ServerCertificateValidationCallback += | |
delegate | |
( | |
Object obj, | |
X509Certificate certificate, | |
X509Chain chain, | |
SslPolicyErrors errors | |
) | |
{ | |
return true; | |
}; | |
} | |
} | |
"@ | |
[ServerCertificateValidationCallback]::Ignore(); | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
$tags = Invoke-RestMethod https://api.github.com/repos/microsoft/vscode/releases | |
$latest = $tags | Foreach-Object { try { [version] $_.tag_name } catch { } } | | |
Sort-Object -Desc | Select-Object -First 1 | |
$current = [Version] (( | |
Get-Content 'C:\Program Files\Microsoft VS Code\resources\app\package.json' | | |
ConvertFrom-Json).Version) | |
if($latest -gt $current) | |
{ | |
$codeWasRunning = @(Get-Process -name Code -ErrorAction Ignore).Count -gt 0 | |
if($codeWasRunning) | |
{ | |
Stop-Process -name Code | |
} | |
Invoke-WebRequest "https://code.visualstudio.com/sha/download?build=stable&os=win32-x64" -OutFile $env:TEMP/vscode_latest.exe | |
if ((Get-AuthenticodeSignature $env:TEMP/vscode_latest.exe).Status -eq 'Valid') | |
{ | |
& $env:TEMP/vscode_latest.exe /verysilent | |
} | |
if(-not $codeWasRunning) | |
{ | |
Stop-Process -Name Code | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment