0

I would like to use a PowerShell script to count lines in a text file. I use this code:

Set-Location -Path D:\
$measure = Get-Content b27.csv | Measure-Object 
$lines = $measure.Count
echo "line count is: ${lines}"

However, I have got error. I think there is something missing to tell pentaho to execute the PowerShell script

After that I try to add this code

powershell.exe -ExecutionPolicy Bypass [D:\]
call Set-Location -Path D:\
call $measure = Get-Content b27.csv | Measure-Object 
call  $lines = $measure.Count
call echo "line count is: ${lines}"

but it doesn't work.

Please find the error as below:

error message

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
SN Palita
  • 87
  • 1
  • 1
  • 9
  • Please post the error message you receive – Mathias R. Jessen Aug 16 '17 at 08:18
  • Your code is PowerShell, but you're invoking a batch file (`.bat`). Rename the file to `.ps1` and remove the line `powershell.exe ...` from it. If that doesn't work you may need to invoke the PowerShell script from a batch file: `powershell.exe -ExecutionPolicy Bypass -File "C:\path\to\your.ps1"`. – Ansgar Wiechers Aug 16 '17 at 08:36
  • I have already edited please find in the first comment – SN Palita Aug 16 '17 at 08:43

1 Answers1

0

Could you use the "Get Files Rows Count" step? It would be cross platform that way.