title: Powershell - "Expressions are only allowed as the first element of a pipeline"
body: <p>Could someone please tell me how to avoid this error in the below circumstance?</p>
  
  <pre><code>$codegenDir = "Z:\Desktop\Song-Renamer"
  $PowerShellRepresentation = dir -path $MyMusicFolder -recurse -include *.mp3,*.m4a,*.wma,*.flac,*.ape | select -ExpandProperty FullName | $codegenDir\codegen.exe -s 10 20 | Out-String | ConvertFrom-Json
  </code></pre>
  
  <p>What completely puzzles me is if simply omit $codegenDir (see below), the code operates correctly.  I "think" I understand the concept of placing the expression first (ahead of other items in the pipeline.  But I'm not sure how to rearrange/split this code so the expression in question <em>the Codegen.exe external commandline</em> is the first item in the pipeline (and still be able to pass data to it via pipeline).</p>
  
  <pre><code>$PowerShellRepresentation = dir -path $MyMusicFolder -recurse -include *.mp3,*.m4a,*.wma,*.flac,*.ape | select -ExpandProperty FullName | .\codegen.exe -s 10 20 | Out-String | ConvertFrom-Json
  </code></pre>
  
  <p>Ideally, it would be nice to do this using the least amount of code as possible.</p>