Powershell - "Expressions are allowed only as the first element of the pipeline"

Can someone please tell me how to avoid this error under the following circumstances?

$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

Which completely puzzles me, just skip $ codegenDir (see below), the code works correctly. I โ€œthinkโ€, I understand the concept of placing an expression in the first place (ahead of other elements in the pipeline. But I'm not sure how to rearrange / break this code, so the expression in question is the external command line of Codegen.exe. (And still have the ability to transfer data through the pipeline).

$PowerShellRepresentation = dir -path $MyMusicFolder -recurse -include *.mp3,*.m4a,*.wma,*.flac,*.ape | select -ExpandProperty FullName | .\codegen.exe -s 10 20 | Out-String | ConvertFrom-Json

Ideally, it would be nice to do this using as little code as possible.

+4
source share
1

( : &):

$PowerShellRepresentation = dir -path $MyMusicFolder -recurse -include *.mp3,*.m4a,*.wma,*.flac,*.ape | select -ExpandProperty FullName | & $codegenDir\codegen.exe -s 10 20 | Out-String | ConvertFrom-Json

, powershell -.

+5

Source: https://habr.com/ru/post/1536253/


All Articles