title: Loop through result of powershell function in batch
body: <p>I have powershell function, which return array of pathes to projects in solution.</p>
  
  <pre><code>function GetPathToSfProj($rootPath, $solutionName){
     $retPath = Get-Content "$($rootPath)\$($solutionName)" |
       Select-String 'Project\((.*\.sfproj)' |
         ForEach-Object {
           $projectParts = $_ -Split '[,=]' | ForEach-Object { $_.Trim('[ "{}]') };
           New-Object PSObject -Property @{
             File = $projectParts[2];
           }
         }
  
     return $retPath.File;
  }
  </code></pre>
  
  <p>I try to execute it from batch file and build package using msBuild.</p>
  
  <pre><code>FOR /F "delims=" %%i IN ('"powershell . ".\GetSfProjPath.ps1 GetPathToSfProj -rootPath "%ProjectLocationPath%" -solutionName "%SolutionName%""; "') DO (
     SET VAL=%%i
     call %MSBuildPath%\MSBuild.exe %VAL% /t:package /p:Configuration=Debug
  )
  </code></pre>
  
  <p>But in loop variable always are NULL</p>
  
  <p>If I test powershell function separatelly, it returns correct result. So problem in batch.</p>