I would like to run a powershell command with batch. My powershell command:
gc 'C:\Users\Test\Test-01\source.csv' | %{
$cols = $_.split(";")
1..$cols[-2]| %{
"$($cols[0..9] -join ';');$($cols[(9+$_)] -join ';');$($cols[(24+$_)] -join ';');;;;;;;;;;;;;;;$($cols[-2]);"
}
} | sc "C:\Users\Test\Test-01\target.csv"
My batch command:
powershell -Executionpolicy ByPass gc 'C:\Users\Test\Test-01\source.csv' | %{
$cols = $_.split(";")
1..$cols[-2]| %{
"$($cols[0..9] -join ';');$($cols[(9+$_)] -join ';');$($cols[(24+$_)] -join ';');;;;;;;;;;;;;;;$($cols[-2]);"
}
} | sc "C:\Users\Test\Test-01\target.csv"
It doesn't work. But why? Can someone say why?