github.com/crowdsecurity/crowdsec@v1.6.1/windows/Chocolatey/crowdsec/tools/chocolateyuninstall.ps1 (about)

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