Q:

Locate MSTest.exe using powershell

I'm in the process of automating my .Net solution build to be completely in PowerShell. I want to locate MSTest.exe using PowerShell.
I used the following script to locate MSBuild.exe and I hope that I can have something similar to locate MSTest.exe
$msBuildQueryResult = reg.exe query "HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0" /v MSBuildToolsPath
$msBuildQueryResult = $msBuildQueryResult[2]
$msBuildQueryResult = $msBuildQueryResult.Split(" ")
$msBuildLocation = $msBuildQueryResult[12] + "MSBuild.exe"

Any directions ?

A:

Thanks @Bill_Stewart , I used your comments to write this working function:
function Get-MSTest-Location {
    $msTests = @()
    $searchResults = Get-ChildItem C:\* -Filter MSTest.exe -Recurse -ErrorAction Ignore
    foreach($searchResult in $searchResults) {
        try{ 
            if(($searchResult.VersionInfo -ne $null) -and ($searchResult.VersionInfo.FileDescription -eq "Test Execution Command Line Tool"))
            { $msTests = $msTests + $searchResult.FullName }
        }
        catch{}
        }
    if($msTests.Length -eq 0)
    {return "MSTest not found."}
    return $msTests[0]
}

