github.com/ddev/ddev@v1.23.2-0.20240519125000-d824ffe36ff3/winpkg/chocolatey/tools/chocolateyuninstall.ps1 (about) 1 2 $ErrorActionPreference = 'Stop'; 3 $packageArgs = @{ 4 packageName = $env:ChocolateyPackageName 5 softwareName = 'ddev*' 6 fileType = 'EXE' 7 silentArgs = "/S" 8 validExitCodes= @(0, 3010, 1605, 1614, 1641) 9 } 10 11 $uninstalled = $false 12 [array]$key = Get-UninstallRegistryKey -SoftwareName $packageArgs['softwareName'] 13 14 if ($key.Count -eq 1) { 15 $key | % { 16 $packageArgs['file'] = "$($_.UninstallString)" 17 if ($packageArgs['fileType'] -eq 'MSI') { 18 $packageArgs['silentArgs'] = "$($_.PSChildName) $($packageArgs['silentArgs'])" 19 20 $packageArgs['file'] = '' 21 } 22 23 Uninstall-ChocolateyPackage @packageArgs 24 } 25 } elseif ($key.Count -eq 0) { 26 Write-Warning "$packageName has already been uninstalled by other means." 27 } elseif ($key.Count -gt 1) { 28 Write-Warning "$($key.Count) matches found!" 29 Write-Warning "To prevent accidental data loss, no programs will be uninstalled." 30 Write-Warning "Please alert package maintainer the following keys were matched:" 31 $key | % {Write-Warning "- $($_.DisplayName)"} 32 } 33 34