Use Out-Host instead of More

by Nov 7, 2014

PowerShell Console

Note that any of this will only work in a “real” console. It will not work in the PowerShell ISE.

To output data page by page, in the PowerShell console many users pipe the result to more.com, like in the old days:

 
PS> dir c:\windows | more 
 

This seems to work well, until you start and pipe more than just a couple of data sets. Now PowerShell appears to hang:

 
PS> dir c:\windows -Recurse -ErrorAction SilentlyContinue | more 
 

That’s because more.com cannot work in real-time. It first collects all incoming data, then starts outputting it page by page.

A much better way is to use the cmdlet Out-Host with the parameter –Paging:

 
PS> dir c:\windows -Recurse -ErrorAction SilentlyContinue | Out-Host -Paging 
 

It yields results immediately because it processes pipeline data as it comes in.

Twitter This Tip! ReTweet this Tip!