Getting the tail of a file in PowerShell (and dropping it into a GridView)
I've had need to wrangle a very long log file recently that gets appended to and doesn't have any log file splitting / cycling baked into it. Changing the logging process so that it generates a separate log file per day has remained relatively low down the list. In the absence of that, a good way to
Get-Content .\.sample.log -Tail 10
This gets the last ten lines of the file which is incredibly useful for massive log files and a PowerShell equivalent of the Linux Tail command.
The way PowerShell commands generate an object can be leveraged to redirect the output from Get-Content to a file:
Get-Content .\sample.log -Tail 10 | Out-File -FilePath .\sample.last10.log
That's pretty much all there is to it, but here's one last thought, you can also use the Out-GridView cmdlet to send the output to a grid view, which of course then lets you search and filter the data, even better:
My skillset has matured somewhat since then, which you'll probably see from the posts here. You can read a bit more about me on the about page of the site, or check out some of the other posts on my areas of interest.