Files
management-scripts/Install-SketchUp.ps1
T

57 lines
2.0 KiB
PowerShell
Raw Normal View History

2020-08-30 23:05:07 -04:00
## Uninstall SketchUp 2016
If ( Test-Path "${Env:ProgramFiles}\SketchUp\SketchUp 2016\SketchUp.exe" )
{
Write-Output "Uninstalling SketchUp 2016..."
Try { Start-Process "msiexec.exe" -ArgumentList '/X{D87EE6DC-32BA-4219-AC75-0A6FD54ED058} /qn /norestart' -Wait }
Catch { Write-Output $_.Exception.Message }
}
## Uninstall SketchUp 2017
If ( Test-Path "${Env:ProgramFiles}\SketchUp\SketchUp 2017\SketchUp.exe" )
{
Write-Output "Uninstalling SketchUp 2017..."
Try { Start-Process "msiexec.exe" -ArgumentList '/X{E59BD84C-169B-4F3F-AC5D-85127CF67051} /qn /norestart' -Wait }
Catch { Write-Output $_.Exception.Message }
}
## Uninstall SketchUp 2019
If ( Test-Path "${Env:ProgramFiles}\SketchUp\SketchUp 2019\SketchUp.exe" )
{
Write-Output "Uninstalling SketchUp 2019..."
Try { Start-Process "msiexec.exe" -ArgumentList '/X{06964675-EB01-6D18-6704-429DE73A8319} /qn /norestart' -Wait }
Catch { Write-Output $_.Exception.Message }
}
## Uninstall SketchUp 2020
If ( Test-Path "${Env:ProgramFiles}\SketchUp\SketchUp 2020\SketchUp.exe" )
{
Write-Output "Uninstalling SketchUp 2020..."
Try { Start-Process "msiexec.exe" -ArgumentList '/X{5778f9a3-781e-16f1-a6bf-08fd59dfa77b} /qn /norestart' -Wait }
Catch { Write-Output $_.Exception.Message }
}
## Define URL for downloading the installer
$URL = 'https://www.sketchup.com/sketchup/2020/SketchUpPro-exe'
$FILE = '{0}\{1}.exe' -f $Env:TEMP,(Split-Path $URL -Leaf)
## Remove previous package
If ( Test-Path $FILE ) { Remove-Item -Path $FILE -Force | Out-Null}
## Download installer
Write-Output "Downloading: ${URL}"
Try { (New-Object System.Net.WebClient).DownloadFile($URL, $FILE) }
Catch { Write-Output $_.Exception.Message }
## Install package
Write-Output "Installing: ${FILE}"
Try { Start-Process -FilePath $FILE -ArgumentList "/silent" -Wait }
Catch { $_.Exception.Message }
## Delete installer package
If ( Test-Path $FILE )
{
Write-Output "Deleting ${FILE}"
Try { Remove-Item -Path $FILE -Force }
Catch { Write-Output $_.Exception.Message }
}