Jtracy_ItPro

Slack_x64-Uninstall_AllUsers.ps1

Sep 18th, 2020 (edited)
749
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Uninstall Slack x64 - "Machine wide" MSI installer
  2.  
  3. $AppName = "Slack Machine-Wide"
  4.  
  5. # Sweep installed apps and pull the uninstall string.
  6. # This is meant to solve the problem of uninstalling auto-patched apps. with automation.
  7. # Secunia will auto-apply new MSIs, which changes the string.
  8. # The config manager client can unisntall with this script, with no regard to the version that's actually installed.
  9.  
  10.  
  11. ##################################################################
  12.  
  13. # Kill processes.
  14.  
  15. $ProcessName = "Slack"
  16.  
  17. Get-Process | ? {$_.name -eq $ProcessName} | % {$_ | Stop-Process -Force -Verbose}
  18.  
  19.  
  20. #######################################################
  21.  
  22. ## Look for both architectures.
  23.  
  24. #$UninstallRoot = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
  25.  
  26. $UninstallRoot = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
  27.  
  28. # Find the first app which matches the name. Be careful to make it find the corret one, in case more than one app matches.
  29.  
  30. # ! ! ! no wildcards this time.
  31.  
  32. $AppInfo = Get-ChildItem -Path $UninstallRoot | Where-Object {$_.getValue("displayname") -eq ($AppName)} | Select-Object -First 1
  33.  
  34. $Version = $AppInfo.GetValue("DisplayVersion")
  35.  
  36. $LogFile = $env:TEMP + "\" + $AppName + "_" + $Version + "-Uninstall.log"
  37.  
  38. $AppGuid = $AppInfo.PSChildName
  39.  
  40.  
  41. # With all this information, run the uninstall command.
  42.  
  43. & MsiExec /x $AppGuid /q /norestart /log $LogFile | Wait-Process
  44.  
Add Comment
Please, Sign In to add comment