]> granicus.if.org Git - icinga2/blob - choco/chocolateyUninstall.ps1
Config parser: inline arraysep
[icinga2] / choco / chocolateyUninstall.ps1
1 $packageName = "Icinga 2";
2 $fileType = 'msi';
3 $silentArgs = '/qr /norestart'
4 $validExitCodes = @(0)
5
6 $packageGuid = Get-ChildItem HKLM:\SOFTWARE\Classes\Installer\Products |
7   Get-ItemProperty -Name 'ProductName' |
8   ? { $_.ProductName -like $packageName + "*"} |
9   Select -ExpandProperty PSChildName -First 1
10
11 $properties = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\$packageGuid\InstallProperties
12
13 $file = $properties.LocalPackage
14
15 # Would like to use the following, but looks like there is a bug in this method when uninstalling MSI's
16 # Uninstall-ChocolateyPackage $packageName $fileType $silentArgs $file -validExitCodes $validExitCodes
17
18 # Use this instead
19 $msiArgs = "/x $file $silentArgs";
20 Start-ChocolateyProcessAsAdmin "$msiArgs" 'msiexec' -validExitCodes $validExitCodes