$Push_Pop = $ErrorActionPreference #Suppresses errors
$ErrorActionPreference = “SilentlyContinue” #Suppresses errors
#Script
#gc .\output\*.csv -ReadCount 5 | %{$_;throw "pipeline end!"} # head
#gc .\output\*.csv | %{$num=0;}{$num++;"$num $_"} # cat -n
gc .\output\*.csv | %{$num=0;}{$num++; if($num -gt 2 -and $num -lt 7){"$num $_"}} # sed
#End Script
$ErrorActionPreference = $Push_Pop #Suppresses errors
You don't get all the errors with the pushpop code BTW, your code only works with the "sed" option. All the rest ignores anything but gc and path.