Question about uninstall using PowerShell and registry value RRS feed

  • Question

  • We are trying to build a PowerShell script to uninstall unneeded apps from a "golden" image the company uses, for use in VDI environment. The script currently looks something like this:

    $vsVer = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall  |
        Get-ItemProperty |
            Where-Object {$_.DisplayName -match "VS*" } |
                Select-Object -Property DisplayName, UninstallString

    ForEach ($ver in $vsVer) {

        If ($ver.UninstallString) {

            $uninst = $ver.UninstallString
            & cmd /c $uninst /quiet /norestart


    This script works great when the value for UninstallString is using an executable or if it is using MsiExec /X {#}, but runs into issues if the value is MsiExec.exe /I{#}. That won't work because we want to uninstall silently and the /I does not allow that, all we get is the Windows Installer Help pop-up.

    Is there a way to retrieve the UninstallString value and trigger a quiet uninstall, instead of using the string value MsiExec.exe /I {#} it uses MsiExec /X {#}?

    We are trying to avoid using Win32_Product.

    Monday, December 11, 2017 8:16 PM


All replies