Skip to content

Instantly share code, notes, and snippets.

@salaros
Created September 25, 2018 17:07
Show Gist options
  • Save salaros/008bb75b28a347151e408d1a88c4ea87 to your computer and use it in GitHub Desktop.
Save salaros/008bb75b28a347151e408d1a88c4ea87 to your computer and use it in GitHub Desktop.
Install-Module VSSetup -Scope CurrentUser
# Copied from:
# https://blogs.msdn.microsoft.com/heaths/2017/04/19/cleaning-up-the-visual-studio-2017-package-cache/
param (
[switch] $Cache
)
$start_args = if ($Cache) {
'repair', '--cache'
} else {
'modify', '--nocache'
}
get-vssetupinstance -all | foreach-object {
$args = $start_args + '--installPath', "`"$($_.InstallationPath)`"", '--passive', '--norestart'
start-process -wait -filePath "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vs_installer.exe" -args $args
if ($LASTEXITCODE -eq 3010) {
$REBOOTREQUIRED = 1
}
}
if ($REBOOTREQUIRED) {
"Please restart your machine"
exit 3010
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment