Sometimes I need to check content of specific file. I usually use SMS Trace (part of SMS 2003 Toolkit). If I don’t have SMS Trace but there is PowerShell on the server, I used to use Get-Content cmdlet.

There is one very useful parameter: Wait. It will allow you to see content of the file on-the-fly. So as lines are coming, your console will show it.

Note: Wait is provider specific parameter so you don’t see it when running Get-Help Get-Content. To see it’s description you need to run Get-Help FileSystem.

Get-Content -Wait

Right console is updating file and changes are immediately visible in left console (Line 1 – Line 5 were in the file already so are returned immediately) and then console is updated every second with new line (Line 100 – Line 105).

Sometimes it’s not necessary (useful) to see all lines coming to the file. So then is possible to filter what you want to see (I wrote the code in ISE so it’s easier to read):

Get-Content -Wait | filter

In the pipeline I am filtering with Where-Object (here represented by it’s alias ‘?’) so see only error lines. Of course, you can use more complex regex for that filtering.