summaryrefslogtreecommitdiffstats
path: root/choco/chocolateyUninstall.ps1
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:32:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:32:39 +0000
commit56ae875861ab260b80a030f50c4aff9f9dc8fff0 (patch)
tree531412110fc901a5918c7f7442202804a83cada9 /choco/chocolateyUninstall.ps1
parentInitial commit. (diff)
downloadicinga2-upstream/2.14.2.tar.xz
icinga2-upstream/2.14.2.zip
Adding upstream version 2.14.2.upstream/2.14.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--choco/chocolateyUninstall.ps120
1 files changed, 20 insertions, 0 deletions
diff --git a/choco/chocolateyUninstall.ps1 b/choco/chocolateyUninstall.ps1
new file mode 100644
index 0000000..a41b351
--- /dev/null
+++ b/choco/chocolateyUninstall.ps1
@@ -0,0 +1,20 @@
+$packageName = "Icinga 2";
+$fileType = 'msi';
+$silentArgs = '/qr /norestart'
+$validExitCodes = @(0)
+
+$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