TAIL command in windows 10

I have been working with Nixie and windows 10 and had on various occasions a need for a running tally of the log file. In linux/unix this is easy, just use the tail command and Bob's yer uncle as they say.

That quest wasn't as straight forward in windows, but, to the rescue windows PowerShell [PS]. PS is very powerful and out of the box comes with restrictions. To be able to run scripts you have to tell the PS that it is ok to trust local scripts. To do this run  PS in admin mode then execute the fillowing command:

Set-ExecutionPolicy RemoteSigned. then answer yes to the allow question.

in notepad, enter the one-liner: Get-Content /nixie/myrobotlab.log -Wait   and save it with a .ps1 extension. I named mine followlog.ps1 and saved it in my nixie directory. you can name yours whatever u like, just adjust the scripts below.

now anytime you want to do a running tail on yer log file just right click on followlog.ps1 and choose Run with PowerShell. (double clicking, for apparent security reasons, opens the file in notepad)


I modified my START_INMOOV.bat file to start the script automatically.

first off, change the line mv myrobotlab.log myrobotlab.log.1 to move /y myrobotlab.log myrobotlab.log.1 as mv is not recognized in windows.


next add the following two lines after the altered move line:

fsutil file createnew myrobotlab.log 0
START powershell -file "c:\nixie\followlog.ps1"
The fsutil line will create an empty log file as u just deleted the current log file by moving it to the backup file. PS is going to need a file to start with, so the fsutil line will create an empty on.
the START line will spawn a PS window tailing the log file as lines are added.
now every time u start inmoov with the bat file, in windows 10 u will have a window showing you the latest lines in the log file.