QuickTime: Remove App using Display Name

email me

This will retrieve a GUID using the Display name you see in Programs and Features, and then uninstall that application using msiexec. What’s great about this ‘scan’ and ‘uninstall’ method is that the GUID doesn’t need to be known and hardcoded into your scripts. This allows for a much more dynamic approach to removing different versions of an application in an automated fashion.

Script 1

$appname = "QuickTime"
 
$32bit = get-itemproperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName, UninstallString | Where-Object { $_.DisplayName -match "$appname"}
$64bit = get-itemproperty 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName, UninstallString | Where-Object { $_.DisplayName -match "$appname"}

$GUID32 = ($32bit.UninstallString -replace 'msiexec.exe /i','' )
$GUID64 = ($64bit.UninstallString -replace 'msiexec.exe /i','' )

cmd /c ("msiexec /qn /x $GUID32")
cmd /c ("msiexec /qn /x $GUID64")

Script 2


$appname = "QuickTime"

$32bit = get-itemproperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName, DisplayVersion, UninstallString, PSChildName | Where-Object { $_.DisplayName -match "^*$appname*"}
$64bit = get-itemproperty 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName, DisplayVersion, UninstallString, PSChildName | Where-Object { $_.DisplayName -match "^*$appname*"}


if ($64bit -eq "" -or $64bit.count -eq 0) {

switch ($32bit.DisplayName.count) {
1 {
if ($32bit -match "msiexec.exe") {
$GUID = ($32bit.UninstallString -replace 'msiexec.exe /i','' )
cmd /c ("msiexec /qn /x")$GUID
}
}
}
}

else {

switch ($64bit.DisplayName.count) {
1 {
if ($64bit -match "msiexec.exe") {
$GUID = ($64bit.UninstallString -replace 'msiexec.exe /i','' )
cmd /c ("msiexec /qn /x")$GUID
}
}
}
}

 

Notes

msiexec /x{B67BAFBA-4C9F-48FA-9496-933E3B255044} /qn /norestart
msiexec /x{8A8505BC-E098-431E-A912-4468C95E110F} /qn /norestart
msiexec /x{929408E6-D265-4174-805F-81D1D914E2A4} /qn /norestart
msiexec /x{08094E03-AFE4-4853-9D31-6D0743DF5328} /qn /norestart
msiexec /x{50D8FFDD-90CD-4859-841F-AA1961C7767A} /qn /norestart
msiexec /x{F07B861C-72B9-40A4-8B1A-AAED4C06A7E8} /qn /norestart
msiexec /x{55BF0E5F-EA8E-4C13-A8B4-9E4857F5A2DE} /qn /norestart
msiexec /x{3868A8EE-5051-4DB0-8DF6-4F4B8A98D083} /qn /norestart
msiexec /x{C21D5524-A970-42FA-AC8A-59B8C7CDCA31} /qn /norestart
msiexec /x{5E863175-E85D-44A6-8968-82507D34AE7F} /qn /norestart