2016-04-14 08:29:58 +02:00
|
|
|
$packageName = "Icinga 2";
|
|
|
|
$fileType = 'msi';
|
|
|
|
$silentArgs = '/qr /norestart'
|
2016-03-13 23:13:01 +01:00
|
|
|
$validExitCodes = @(0)
|
2016-04-14 08:29:58 +02:00
|
|
|
|
|
|
|
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
|
2016-03-13 23:13:01 +01:00
|
|
|
}
|
2016-04-14 08:29:58 +02:00
|
|
|
catch {
|
|
|
|
Write-ChocolateyFailure $package "$($_.Exception.Message)"
|
|
|
|
throw
|
2016-03-13 23:13:01 +01:00
|
|
|
}
|