How can I view a log file from powershell console ? (i.e. powershell equivalent of 'less')

user331465 picture user331465 · May 20, 2011 · Viewed 31.3k times · Source

What is the powershell equivalent of 'less'?

I see 'more', but it lacks some of the features I rely on (e.g. searching through the file)

I seek a pager (equivalent of 'less') which allows searching (match or ignore case), multiple files at once, etc.

Some of our servers run windows 2008 and I lack admin privileges to install cygwin

I had heard windows 2008, MSFT got their act together and provided some easy-for-admins tools.

Update:

I should give some context:

  • I know little about power shell
  • New servers have 2008 on them
  • While I affection for many tools of yore, the dos prompt is not one of them
  • I was hoping that Powershell had the equivalent of grep,ls,less, xargs, et
  • I understood that powershell gave us those tools
  • I fired off my question quickly.

thanks

Answer

Matt picture Matt · May 21, 2011

It reads like you know you can do this:

gc logfile.log | more

(GC is an alias for Get-Content).

You may be able to do the filtering etc.. with this more information can be found by running these commands:

Get-Help Get-Content Get-Help

Get-Content -Examples

(Get-Help gc would work fine as well).

And the bits you may be interested in are limit\filter etc...

Get-Help gc -Parameter * | more