Windows Installer Troubleshooter

We’ve had to occasionally run this tool to uninstall Screenconnect if someone wiped the original setup.msi package. Does anyone have any powershell that can use this tool against a known software? We can get the package name, etc. from powershell using wmi, etc. just need to run the tool to do whatever it does.

Fix problems that block programs from being installed or removed (microsoft.com)

TIA,
Carlos

I don’t know how well it will work generally, but this is what I figured out for fixing broken ScreenConnect agents that won’t upgrade:

$name = "ScreenConnect Client (b7fb61blahblahblah)"
Get-ChildItem "HKLM:\SOFTWARE\Classes\Installer\Products\*\" | Get-ItemProperty | Where-Object ProductName -like "$name" | Remove-Item -Recurse -Force
Get-ChildItem "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" | Get-ItemProperty | Where-Object DisplayName -like "$name" | Remove-Item -Recurse -Force