## Version of SketchUp to install $InstallVersion = "2020" ## Make sure we have an administrative token If ( IsAdmin ) { ## Define URL for downloading the installer $URL = "https://www.sketchup.com/sketchup/${InstallVersion}/SketchUpPro-exe" ## Make sure the URL is valid before we do anything If ( IsURLValid $URL ) { ## Uninstall SketchUp 2016 If ( Test-Path "${Env:ProgramFiles}\SketchUp\SketchUp 2016\SketchUp.exe" ) { LogMsg "Uninstalling SketchUp 2016" Try { Start-Process "msiexec.exe" -ArgumentList '/X{D87EE6DC-32BA-4219-AC75-0A6FD54ED058} /qn /norestart' -Wait } Catch { LogErr $_.Exception.Message } } ## Uninstall SketchUp 2017 If ( Test-Path "${Env:ProgramFiles}\SketchUp\SketchUp 2017\SketchUp.exe" ) { LogMsg "Uninstalling SketchUp 2017" Try { Start-Process "msiexec.exe" -ArgumentList '/X{E59BD84C-169B-4F3F-AC5D-85127CF67051} /qn /norestart' -Wait } Catch { LogErr $_.Exception.Message } } ## Uninstall SketchUp 2019 If ( Test-Path "${Env:ProgramFiles}\SketchUp\SketchUp 2019\SketchUp.exe" ) { LogMsg "Uninstalling SketchUp 2019" Try { Start-Process "msiexec.exe" -ArgumentList '/X{06964675-EB01-6D18-6704-429DE73A8319} /qn /norestart' -Wait } Catch { LogErr $_.Exception.Message } } ## Uninstall SketchUp 2020 If ( Test-Path "${Env:ProgramFiles}\SketchUp\SketchUp 2020\SketchUp.exe" ) { LogMsg "Uninstalling SketchUp 2020" Try { Start-Process "msiexec.exe" -ArgumentList '/X{5778f9a3-781e-16f1-a6bf-08fd59dfa77b} /qn /norestart' -Wait } Catch { LogErr $_.Exception.Message } } ## Set the local file name to download to $FILE = '{0}{1}.exe' -f (GetTempPath),(Split-Path $URL -Leaf) ## Download installer $FILE = Download-File -URL $URL -File $FILE ## Install package Install-Program -Path $FILE -Arguments "/silent" -Delete } }