How to use PowerShell to tail a log file

The unix "tail" command allows a user to view the end of a log file. The command "tail -f filename" will watch the file and display any new lines as they are written to the log file.

There is a powershell equivalent to this. See this article on TechNet.

Step-by-step guide

1.Open Powershell

2.Change to the log folder

cd C:\ProgramData\iQuate\iQSonar4.0\Logs

The Get-Content cmdlet with the Tail parameter will list the last number of lines from the file


If you want to get the effect of "tail -f", use the "-Wait" parameter on the end as well.

Change Directory to the folder containing the log

Type the Get-Content cmdlet with both "-tail N" and "-wait" together

example:

cd C:\ProgramData\iQuate\iQSonar4.0\Logs
get-content service.log -tail 10 -wait

Will display the last 10 lines of the service log, and will then continue displaying any new lines until

the user presses CTRL-C