Log Tail with PowerShell

I needed a way to monitor the output of the Dynamics CRM trace log file and stupidly went GoogleBing-ing for a “tail” equivalent application for Windows. I should have known to turn to trusted PowerShell!

Get the last 10 lines of a log file:

Get-Content mylogfile.log -Tail 10

Get the first 20 lines of a log file:

Get-Content mylogfile.log -Head 20

Monitor a live log file:

Get-Content mylogfile.log -Wait

Monitor a live log file but only print the last 5 lines when starting up:

Get-Content mylogfile.log -Wait -Tail 5