From: Gunnar Beutner Date: Wed, 3 Jan 2018 09:35:52 +0000 (+0100) Subject: Remove deprecated Chocolatey functions X-Git-Tag: v2.9.0~223^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=refs%2Fpull%2F5940%2Fhead;p=icinga2 Remove deprecated Chocolatey functions --- diff --git a/choco/chocolateyUninstall.ps1 b/choco/chocolateyUninstall.ps1 index d5babe70f..a41b35192 100644 --- a/choco/chocolateyUninstall.ps1 +++ b/choco/chocolateyUninstall.ps1 @@ -2,27 +2,19 @@ $packageName = "Icinga 2"; $fileType = 'msi'; $silentArgs = '/qr /norestart' $validExitCodes = @(0) - -try { - $packageGuid = Get-ChildItem HKLM:\SOFTWARE\Classes\Installer\Products | - Get-ItemProperty -Name 'ProductName' | - ? { $_.ProductName -like $packageName + "*"} | - Select -ExpandProperty PSChildName -First 1 - - $properties = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\$packageGuid\InstallProperties - - $file = $properties.LocalPackage - - # Would like to use the following, but looks like there is a bug in this method when uninstalling MSI's - # Uninstall-ChocolateyPackage $packageName $fileType $silentArgs $file -validExitCodes $validExitCodes - - # Use this instead - $msiArgs = "/x $file $silentArgs"; - Start-ChocolateyProcessAsAdmin "$msiArgs" 'msiexec' -validExitCodes $validExitCodes - - Write-ChocolateySuccess $package -} -catch { - Write-ChocolateyFailure $package "$($_.Exception.Message)" - throw -} + +$packageGuid = Get-ChildItem HKLM:\SOFTWARE\Classes\Installer\Products | + Get-ItemProperty -Name 'ProductName' | + ? { $_.ProductName -like $packageName + "*"} | + Select -ExpandProperty PSChildName -First 1 + +$properties = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\$packageGuid\InstallProperties + +$file = $properties.LocalPackage + +# Would like to use the following, but looks like there is a bug in this method when uninstalling MSI's +# Uninstall-ChocolateyPackage $packageName $fileType $silentArgs $file -validExitCodes $validExitCodes + +# Use this instead +$msiArgs = "/x $file $silentArgs"; +Start-ChocolateyProcessAsAdmin "$msiArgs" 'msiexec' -validExitCodes $validExitCodes