title: Mstest on Jenkins outputs undesired UTF-8 characters after first call in a foreach loop
body: <p>I am currently trying to set up a CI pipeline for one of our softwares using Jenkins. I'm at the step where I need to run each separate test file with MsTest. From what I've read, unlike NUnit or other popular test frameworks, MsTest does not let you run all tests from the solutions folder. I have to recursively check every folder in the solution folder and manually run every test container in a ForEach-Object loop. At the moment, the first few test suites run perfectly and print out the log. However, about midway through the testing phase, some weird characters appear in the Jenkins log, and it seems to cause the tests to fail.</p>
  
  <p>I have looked online and in most similar cases, people who ran into this issue had an older version of a plugin, which is not my case. We are using Jenkins 2.15 and PowerShell 4.0. Here's the code from the testing stage.</p>
  
  <pre><code>    stage ('Unit tests') {
              steps {
                  script {
                      powershell("""
                          Get-ChildItem -Path .\\*\\bin\\*Tests.dll -Recurse | 
                              ForEach-Object {
                                  \$obj = \$_;
                                  &amp; \"${tool 'MsTest'}\" /category:.\"ExpectedState|CurrentState|Uncategorized\" /testcontainer:\"\$obj\";
                              }
                      """)
                  }
  
              }
          }
  </code></pre>
  
  <p>Here's part of the output from the Jenkins Log</p>
  
  <blockquote>
    <p>Microsoft (R) Test Execution Command Line Tool Version 14.0.23107.0
    Copyright (c) Microsoft Corporation. All rights reserved.</p>
    
    <p>Loading D:\jenkins-workspace\workspace\MultiBranch_Pipeline\Acceptance.Tests\bin\Release\Acceptance.Tests.dll...
    Starting execution...</p>
    
    <p>Summary</p>
    
    <blockquote>
      <p>Test Run Inconclusive.</p>
      
      <blockquote>
        <p>Inconclusive  7</p>
        
        <p>Total         7</p>
      </blockquote>
    </blockquote>
    
    <p>Results file:  D:\jenkins->workspace\workspace\MultiBranch_Pipeline\TestResults\JenkinsAdmin 2019-04-02 13_47_54.trx</p>
    
    <p>Test Settings: Default Test Settings</p>
  </blockquote>
  
  <p>Then eventually later in the ForEach loop</p>
  
  <blockquote>
    <p>Starting execution...
    No tests to execute.</p>
    
    <blockquote>
      <p>powershell.exe : ï»¿ï»¿ï»¿ï»¿ï»¿ï»¿</p>
    </blockquote>
    
    <p>At D:\jenkins-workspace\workspace\MultiBranch_Pipeline\durable-5fe1\powershellWrapper.ps1:3 char:1
    + &amp; powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "&amp; 'D:\ ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</p>
    
    <ul>
    <li>CategoryInfo          : NotSpecified: (ï»¿ï»¿ï»¿ï»¿ï»¿ï»¿:String) [], RemoteException</li>
    <li>FullyQualifiedErrorId : NativeCommandError</li>
    </ul>
  </blockquote>
  
  <p>These weird characters seem to spawn pretty randomly and I'm not sure exactly what makes them appear. Is this a problem on my end or rather with one of the plugins ? </p>
  
  <p>Sorry if this has been asked before, I could not find a solution in the cases I have seen online. Thanks for taking the time to read.</p>