I am trying to get the uninstall paths of a set of applications and uninstall them. So far i an get the list of uninstall paths. but i am struggling to actually uninstall the programs.
My code so far is.
$app = @("msi1", "msi2", "msi3", "msi4")
$Regpath = @(
'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
)
foreach ($apps in $app){
$UninstallPath = Get-ItemProperty $Regpath | where {$_.displayname -like "*$apps*"} | Select-Object -Property UninstallString
$UninstallPath.UninstallString
#Invoke-Expression UninstallPath.UninstallString
#start-process "msiexec.exe" -arg "X $UnistallPath /qb" - wait
}
this will return the following results:
MsiExec.exe /X{F17025FB-0401-47C9-9E34-267FBC619AAE}
MsiExec.exe /X{20DC0ED0-EA01-44AB-A922-BD9932AC5F2C}
MsiExec.exe /X{29376A2B-2D9A-43DB-A28D-EF5C02722AD9}
MsiExec.exe /X{18C9B6D0-DCDC-44D8-9294-0ED24B080F0C}
Im struggling to find away to execute these uninstall paths and actually uninstall the MSIs.
I have tried to use Invoke-Expression $UninstallPath.UninstallString but it just displays the windows installer and gives me the option for msiexec.
I have also tried to use start-process "msiexec.exe" -arg "X $UnistallPath /qb" - wait however this gives the same issue.