title: Script ran successfully but still software is not uninstalled
body: <blockquote>
  <p>Even though the below script runs successfully to remove software, I
  am still able to see the software in the control panel program list,
  what I am doing wrong?</p>
  </blockquote>
  <p>See the command below :</p>
  <blockquote>
  <p>PS D:\Project&gt;  .\ScriptWithBelowCode.ps1 -ComputerName
  &quot;X-XXX50947&quot; -AppGUID XXXXXX-A60B-4899-A369-XXXXXXX
  Uninstallation command triggered successfully</p>
  </blockquote>
  <pre><code>[cmdletbinding()]            
  
  param (            
  
   [parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
   [string]$ComputerName = $env:computername,
   [parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Mandatory=$true)]
   [string]$AppGUID
  )            
  
   try {
    $returnval = ([WMICLASS]&quot;\\$computerName\ROOT\CIMV2:win32_process&quot;).Create(&quot;msiexec `/x$AppGUID `/norestart `/qn&quot;)
   } catch {
    write-error &quot;Failed to trigger the uninstallation. Review the error message&quot;
    $_
    exit
   }
   switch ($($returnval.returnvalue)){
    0 { &quot;Uninstallation command triggered successfully&quot; }
    2 { &quot;You don't have sufficient permissions to trigger the command on $Computer&quot; }
    3 { &quot;You don't have sufficient permissions to trigger the command on $Computer&quot; }
    8 { &quot;An unknown error has occurred&quot; }
    9 { &quot;Path Not Found&quot; }
    9 { &quot;Invalid Parameter&quot;}
   }
  
  
  Command to execute .\ScriptFileWithAboveContent.ps1 -ComputerName &quot;X-15XX150947&quot; -AppGUID 30F836D2-A60B-4899-A369-XXXXX884EAF
  
  
  Command to get GUID 
  Get-WmiObject -Class Win32_Product ` -Filter &quot;Name like '%Microsoft%'&quot; | Select-Object -ExpandProperty IdentifyingNumber
  </code></pre>
  <p><em><strong>Second try</strong></em></p>
  <pre><code>$app = Get-WmiObject -Class Win32_Product | Where-Object {$_.IdentifyingNumber -match &quot;XXXXXX-A60B-4899-XXXX-B0FXXX84EAF&quot; }
      $app.Uninstall()
  </code></pre>
  <p>I am getting error showing below</p>
  <pre><code> PS D:\Project&gt; .\ScriptFileWithAboveContent.ps1
      Exception calling &quot;Uninstall&quot; : &quot;Operation is not valid due to the current state of the object.&quot;
      At D:\MicrosoftAIM\ScriptFileWithAboveContent.ps1:2 char:5
      +     $app.Uninstall()
      +     ~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : WMIMethodException
  </code></pre>
  <p><em><strong>Third try</strong></em></p>
  <p>The below script ran successfully, But still, the software is still in the program list.</p>
  <pre><code>echo &quot;Getting product code&quot;
  $ProductCode = Get-WmiObject win32_product -Filter &quot;Name like '%somesoftware%'&quot; | Select-Object -Expand IdentifyingNumber
  echo &quot;removing Product&quot;
  # Out-Null argument is just for keeping the power shell command window waiting for msiexec command to finish else it moves to execute the next echo command
  &amp; msiexec /x $ProductCode | Out-Null
  echo &quot;uninstallation finished&quot;
  
  
  PS D:\MicrosoftAIM&gt; .\ScriptWithAboveContent.ps1
  Getting product code
  removing Product
  uninstallation finished
  PS D:\MicrosoftAIM&gt; Get-WmiObject -Class Win32_Product ` -Filter &quot;Name like '%Microsoft%azure%info%'&quot;
  </code></pre>