Topics: Archive - Toolkit Extensions
Apr 28, 2014 at 9:05 AM
Mighty all, I have started working on a function to remove MSIs by GUIDs, as sometimes in our environment applications do not register by app name, but only by MSI GUIDs. This is an early cut, so feel free to contribute :)
function Remove-MsiByGUID {
       Performs removal of a particular GUID
       Changes to user install mode for Remote Desktop Session Host/Citrix servers
       Remove-MsiByGUID -GUID "{594ABD08-C02C-4827-8ABF-A128006848A3}"
       Param (

    [Parameter(Mandatory=$True, HelpMessage="GUIDs to remove if a per-user installation will be detected")] 
       [string]$GUID = $null,
       [int]$Retries = $null
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = "$env:SystemRoot\System32\msiexec.exe"
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = "/x $GUID /qb /l*v $LogPath\$GUID.log"
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
if ($Retries -eq $null) {$Retries = 2}
       do {
Write-Log -Text "Starting attempt # $i to remove $guid."      

$p.Start() | Out-Null
Write-Log -Text "Removal started, waiting for process to terminate." 
Write-Log -Text "Process stopped."
$result = $p.ExitCode      
Write-Log -Text "Return code was $result"
if ($result -eq "3010"){Write-Log -Text "Information: Process returned 3010, consider rebooting, would you AI??."}

              } until (($i = $Retries) -or ($result -eq "1605") -or ($result -eq "1603"))

if ($result -eq "1603"){Write-Log -Text "Process returned 1603 - stopping further attempts to remove."}
elseif ($i -eq "3") {Write-Log -Text "Tried to remove $GUID 2 times, gving up"}

Apr 30, 2014 at 6:01 PM
Nice job :)
May 2, 2014 at 6:55 AM
Dear all,

sorry for asking, but what is the difference between this function and "Execute-MSI -Action Uninstall -Path..." ?

It isn't clear for me :-(

May 2, 2014 at 8:35 AM
For example MSI could be no longer available on the target system