PoSH simply starts the installer / uninstaller (.msi, .exe). If the installer / uininstaller does not have a silent option, there is nothing PoSH can do about that. The RegKey uninstall string is only calling the original installer used to deploy the application.
See this post for a similar discussion.
How can I uninstall an application using PowerShell?
Using the WMI object takes forever. This is very fast if you just know the name of the program you want to uninstall.
$uninstall32 = gci "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match "SOFTWARE NAME" } | select UninstallString
$uninstall64 = gci "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match "SOFTWARE NAME" } | select UninstallString
if ($uninstall64) {
$uninstall64 = $uninstall64.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X",""
$uninstall64 = $uninstall64.Trim()
Write "Uninstalling..."
start-process "msiexec.exe" -arg "/X $uninstall64 /qb" -Wait}
if ($uninstall32) {
$uninstall32 = $uninstall32.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X",""
$uninstall32 = $uninstall32.Trim()
Write "Uninstalling..."
start-process "msiexec.exe" -arg "/X $uninstall32 /qb" -Wait}
Other example(s)s:
https://social.technet.microsoft.com/Forums/scriptcenter/en-US/60e06261-f134-41e8-9f99-6bada23a6f02/using-registry-uninstallstring-to-remove-software?forum=winserverpowershell
$javaVer = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
Get-ItemProperty |
Where-Object {$_.DisplayName -match "java" } |
Select-Object -Property DisplayName, UninstallString
ForEach ($ver in $javaVer) {
If ($ver.UninstallString) {
$uninst = $ver.UninstallString
& cmd /c $uninst /quiet /norestart
}
}
Search for and Uninstall Software on Remote or Local Computer via
Powershell
This script searches for and attempts to uninstall a piece of software
by product name. It queries the SCCM client's WMI class for the
product, finds the uninstall string and executes the uninstall string.
https://gallery.technet.microsoft.com/scriptcenter/Search-for-and-Uninstall-8c2c457e