I am trying to create a PS script in order to retrieve a specific Software Name and then execute the Uninstall String in Silent Mode, No Reboot and SilentlyContinue.
For some reason when I try to execute the command, I receive the error message where the term MSIEXEC.EXE is not recognized. However if I try to execute using CMD line, everything works fine.
Any suggestion what is wrong? Below my script:
$PathUninstall = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
Get-ChildItem $PathUninstall|
Where-Object{ $_.GetValue('DisplayName') -like '%Software_Name%' } |
ForEach-Object{
$uninstallString = $_.GetValue('UninstallString') + '/qn REBOOT=REALLYSUPPRESS'
Write-Host $uninstallString
& $uninstallString
}