Today at my class a student tried to read the last line of a BDD.log file using the “Read Line” activity and setting the lines to “LASTLINE:1”

This is the usual method for reading a text file, and it usually works!

but in this case we got a weird result!

not only one, but 8 lines was read and when we tested on another file, the output was 12 lines!

 

concluding that the “Read Line” activity must have some kind of bug, we switched to a PowerShell Script:

$FilePath = "\\SERVER01\MDTLogs\BDD.local"
$LastLine = Get-Content $FilePath | Select-Object -Last 1

 

Add this to your Runbook using the “Run .Net Script” Activity

image

And map the “LastLine” variable to published data:

image