title: How to run mstest with VSTEST.CONSOLE.EXE in powershell
body: <p>After reading and experimenting available posts in Stack overflow I am asking this question. </p>
  
  <p>I'm struggling to trigger MSTEST in powershell </p>
  
  <p>Here is my attempt (obviously with the help of posts available in stack overflow)</p>
  
  <pre><code>$testDLL = "C:\Automation\Tests\My.Tests.dll"
  $fs = New-Object -ComObject Scripting.FileSystemObject
  $f = $fs.GetFile("C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe")
  $vstestPath = $f.shortpath   
  $arguments = " " + $testDLL + ' /TestCaseFilter:"TestCategory=FunctionalTests"'
  Write-Host $arguments
  &amp; $vstestPath $arguments
  </code></pre>
  
  <p>Console Output:</p>
  
  <pre><code>    PS C:\Users\myuser\Desktop\Powershell scripts&gt; .\exp5.ps1
       C:\Automation\Tests\My.Tests.dll /TestCaseFilter:"TestCategory=FunctionalTests"
      Microsoft (R) Test Execution Command Line Tool Version 15.9.1
      Copyright (c) Microsoft Corporation.  All rights reserved.
  
      VSTEST~1.EXE : The test source file "C:\Automation\Tests\My.Tests.dll /TestCaseFilter:TestCategory=FunctionalTests" provided was not found.
      At C:\Users\myuser\Desktop\Powershell scripts\exp5.ps1:7 char:1
      + &amp; $vstestPath $arguments
      + ~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (The test source... was not found.:String) [], RemoteException
          + FullyQualifiedErrorId : NativeCommandError
  
      Usage: vstest.console.exe [Arguments] [Options] [[--] &lt;RunSettings arguments&gt;...]]
  
      Description: Runs tests from the specified files.
  
      Arguments:
  
      [TestFileNames]
            Run tests from the specified files. Separate multiple test file names
  .
  .
  .
  . etc
  </code></pre>
  
  <p>If I run in normal windows cmd prompt then tests are running without any problem but when I tried to trigger from powershell getting above error.</p>
  
  <p>can someone help me what is wrong with my script.</p>
  
  <p>If my script is complicated or doesn't make sense please excuse me as I'm novice in powershell. My goal is to use the above powershell script in Octopus Deploy step process to trigger tests. If anyone know easy or better way of doing it please share...</p>
  
  <p>Thank you</p>