title: PSRemotingTransportException when calling Start-Process "MsiExec.exe" on remote machine
body: <p>I am trying to run the following command on a remote computer to uninstall the previous version of a product before I install another version.  This is uninstalling using MsiExec.exe.</p>
  
  <p>Whenever I call Start-Process, the process actually runs and the product is uninstalled on the remote computer, but I get the below exception thrown.  If the product is not already installed and the Start-Process line does not run, the remote command works fine with no thrown exception.  (i.e. it actually searches the registry, does not find the product, and returns -1 without throwing an exception)  The problem only arises when Start-Process is called.</p>
  
  <p>Here's my script code...</p>
  
  <pre><code>$UninstallScriptBlock = {
      param ( [string]$InstallerProductName )
  
      $ErrorActionPreference = "Stop";
  
      $UninstallRegPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
      $ProductCode = Get-ChildItem -Path $UninstallRegPath | foreach { if ($_.GetValue("DisplayName") -eq $InstallerProductName) { [System.IO.Path]::GetFileName($_); } }
      if ([string]::IsNullOrEmpty($ProductCode))
      {
          $UninstallRegPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
          $ProductCode = Get-ChildItem -Path $UninstallRegPath | foreach { if ($_.GetValue("DisplayName") -eq $InstallerProductName) { [System.IO.Path]::GetFileName($_); } }
      }
      if ([string]::IsNullOrEmpty($ProductCode))
      {
          return -1;
      }
  
      $Process = Start-Process -Wait -Passthru -FilePath "MsiExec.exe" -ArgumentList "/X", $ProductCode, "/qn";
      return $Process.ExitCode;
  }
  
  [int]$UninstallReturnCode = Invoke-Command -ComputerName $Server -ScriptBlock $UninstallScriptBlock -ArgumentList $InstallerProductName -SessionOption (New-PSSessionOption -OperationTimeout 0);
  </code></pre>
  
  <p>And the thrown exception...</p>
  
  <pre><code>Processing data for a remote command failed with the following error message: The I/O operation has been aborted because of either a thread exit or an application request. For more information, see the about_Remote_Troubleshooting Help topic.
  At [Undisclosed]
  +     [int]$UninstallReturnCode = Invoke-Command -ComputerName $Server -ScriptBloc ...
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  + CategoryInfo          : OperationStopped: ([UndisclosedServerName]:String) [], PSRemotingTransportException
  + FullyQualifiedErrorId : JobFailure
  + PSComputerName        : [UndisclosedServerName]
  </code></pre>
  
  <p>And the formatted error...</p>
  
  <pre><code>ErrorCode                   : 995
  TransportMessage            : The I/O operation has been aborted because of either a thread exit or an application request.
  
  ErrorRecord                 : Processing data for a remote command failed with the following error message: The I/O
                                operation has been aborted because of either a thread exit or an application request. For
                                more information, see the about_Remote_Troubleshooting Help topic.
  StackTrace                  :
  WasThrownFromThrowStatement : False
  Message                     : Processing data for a remote command failed with the following error message: The I/O
                                operation has been aborted because of either a thread exit or an application request. For
                                more information, see the about_Remote_Troubleshooting Help topic.
  Data                        : {}
  InnerException              :
  TargetSite                  :
  HelpLink                    :
  Source                      :
  </code></pre>