Tailing a File With PowerShell

Monitoring log files from a Windows PowerShell prompt can be just as convenient as using bash for this activity.  The following commands will output an active display of a live log file.

Where the integer represents the number of lines to display in the buffer.  Wait instructs the command to load new lines as they are written to the file.

1
Get-Content -Path "c:\example.log" -Wait -Tail 10

you can alternatively write this expression using the cat command:

1
2
3
4
# Print whole file and wait for appended lines and print them
cat "c:\example.log" -Wait
# Print last 10 lines and wait for appended lines and print them
cat "c:\example.log" -Tail 10 -Wait
Lima

About the author

Lima is the visual nautical indicator for "stop instantly."

Leave a Reply