Is there a way to paginate output by piping it to a more
or less
command, similar to those that are available in Linux\Unix shells?

- 16,507
- 9
- 88
- 138

- 24,971
- 33
- 103
- 152
-
8For those who don't know less, some cool things about it is that you can go backwards, use arrows, use page up/down and even search using the key '/' and have the results highlighted. – Constantino Cronemberger Mar 08 '20 at 11:47
15 Answers
Yes there is:
some-cmdlet | out-host -paging
-
1I had used more and less before, neither being quite as user friendly as I should think possible. I found this variation to be more useful/usable than the others. Thanks very much. – TheXenocide Jun 17 '10 at 20:32
-
For printing the content of a very large file this worked very nice for me as the Get-Content cmdlet started immedialety to pipe the contents to the out-host cmdlet. – Germán Sep 15 '10 at 08:24
-
15Note that the -Paging parameter of Out-Host is not supported in the PowerShell ISE. – Martin Hollingsworth Sep 15 '11 at 23:37
-
@BrunoBrant That's not the point. You could pipe the output to anything; `less` is just a big text viewer application that accepts `stdin` for the text. You could pipe it to a temp file and open it in `nano` or `vim` for EVEN MOAR POWERRRR! Not the point. PowerShell is like `bash` (but better, imho). `less` is not in `bash`; it's a separate binary. So your criticism is not valid. – Alan McBee Dec 16 '17 at 19:26
-
@AlanMcBee, I must love flamebait: 1) "you could pipe the output to anything": yep, and as you said, that's not the point. 2) "Powershell is like bash": and like cmd, and like any other shell ever made. But powershell is object oriented and not text based, which is a GREAT difference. 3) "less is not in bash". So what? Did I mentioned bash? If I was building a shell I'd do my user a favor of including a less-like tool. That's all I was saying. – Bruno Brant Dec 18 '17 at 17:31
-
@BrunoBrant re flamebait: I know the feeling. Sorry. But less is not bundled w PS (nor CMD), so your comment felt more like a "Windows sucks" snub than anything helpful (although I agree that `less` is A Very Cool Thing, if you can't use PS ;-) ). The OO feature is not a detriment; you can always treat text like an object if you want. OO lets you work with streams over several pipes in more powerful ways than text, if you want. All said, however, I totally agree that PS would be better if it had `less` in it. – Alan McBee Dec 18 '17 at 18:06
-
11Also, comment on the answer: the alias `oh` is for `Out-Host`, and parameters can be abbreviated if there's no conflict, so the command could be `Some-Cmdlet | oh -p` – Alan McBee Dec 18 '17 at 18:10
-
@AlanMcBee The point is that most Unix-like distributions includes the “less” pager, but Windows doesn’t provide an equivalent pager. I currently pipe it into the less in my MinGW64, but it doesn’t feel native. – Franklin Yu Jan 31 '18 at 15:54
-
1@TheXenocide How is out-host -paging more useful/usable than the others? – brendan Apr 26 '19 at 10:49
-
@brendan Wish I could tell you, but I honestly don't remember; that comment is from 9 years ago :-/ – TheXenocide Jul 08 '19 at 18:24
-
This is not About recursion here, but if one is interested in the [`-rec`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-childitem?view=powershell-6) alias, see the link. – Timo Oct 15 '19 at 08:31
-
Well... There is "more", which is more or less (...) the same you'd expect from other platforms. Try the following example:
dir -rec | more

- 2,244
- 1
- 18
- 12
-
1more does exactly that, when you take a look at the definition of the function with gcm more|select Definition|fl – Joey Jul 03 '09 at 12:37
-
3Actually, piping to more is equal to piping to "out-host -paging", which is separate from the more.com implementation. In practice there is no discernable difference though. – Jouni Heikniemi Jul 03 '09 at 12:50
-
Neither in PS1 on Vista nor PS2 on Win7, at least for me. "more" is a function which does a little work beforehand and then just calls more.com. Out-Host -Paging is separate from that (and doesn't depend on more.com). The difference is most noticeable when you use something that doesn't return right away, such as your gci -rec example. Piping to Out-Host is immediate, as it can process the input one line at a time, piping to more takes time as PS first collects all lines and then sends them to more.com. – Joey Jul 03 '09 at 13:23
-
2Interesting! For me, gcm more returns two definitions, one is a PowerShell function that, when given an empty argument, does "$input | out-host -p", which is the behavior I'm seeing on gci -rec | more. On the other hand, when I do gci -rec | more.com, I get the normal more.com behavior. On W7 RC with PS2 installed, I also seem to get more.com even when typing just "more". On Vista with PS1, the behavior described above occurs. Based on http://huddledmasses.org/powershell-power-user-tips-get-command-precedence/, wouldn't you think the function should be executed on W7 also? Hmm... – Jouni Heikniemi Jul 03 '09 at 14:15
-
1Sorry, that wasn't particularly well-written. So my point was that on Vista with PowerShell 1, piping to just "more" invokes Out-Host -p while on W7 with PowerShell 2 it invokes more.com. – Jouni Heikniemi Jul 03 '09 at 14:17
-
1Eep, I stand corrected. Sorry. Yes, indeed, in PS 1 it invokes Out-Host -p, not more.com (note to self: Always read the whole function, even if it looks very similar) – Joey Jul 04 '09 at 00:59
-
more lacks features such as moving backwards, moving forward with `f` and filtering and searching. – noɥʇʎԀʎzɐɹƆ Jun 13 '20 at 22:18
-
Thank you. This answer saved my life and I could actually do stuff while stuck on Windows! – Dmitry Kamenetsky Aug 10 '22 at 12:50
dir -rec | more
is bad advice.
It will cause powershell to evaluate the entire command prior to outputting it to the screen, something that is not needed for something like output paginating
In some extreme cases, it could cause the system to crash (e.g. dir 'C:\' | more
)
On the other hand, using out-host -paging
will output information to the screen as it is available.

- 2,980
- 24
- 31

- 447
- 4
- 2
-
3When you use remote powershell and want to pipe a command on the remote windows server through a pager, piping through `out-host -paging` works as desired. Piping through `more` when running the remote command is of no use: the entire text is displayed at once. – IllvilJa Feb 22 '13 at 10:35
-
12
The Powershell Community Extensions have a handy function named 'less' that provides a more complete Unix-style feature set, using a ported copy of less.exe to actually handle the paging.
You can install it by starting an admin shell and running:
Find-Package pscx | Install-Package -Force
(the force
is to upgrade older versions)
You can pipe strings to it, or give filenames as direct parameters.
type foo.txt | less
less foo.txt, bar.txt, baz.txt
It works in ConEmu and Powershell windows, but unfortunately it doesn't work the way you'd expect under the v2.0 ISE.

- 8,920
- 6
- 43
- 57

- 20,629
- 2
- 66
- 86
-
9The installation overrides several basic Powershell commands (gcb,Expand-Archive,Format-Hex,Get-Hash,help,prompt,Get-Clipboard,Get-Help,Set-Clipboard) so saying "the `force` is to upgrade older versions" seems a little bit misleading. – TNT Aug 12 '18 at 08:33
-
1just installing for current user without errors or warnings use: `Find-Package pscx | Install-Package -Force -scope currentuser -allowclobber` – Andreas Covidiot Sep 07 '18 at 13:15
-
-
I prefer the "less" command over the "more" command. With the less command, results can also be paged backwards instead of just forwards.
The "less" from Git for Windows works for me*
To save typing I added the alias "l" for less in my Powershell profile (notepad $profile
):
Set-Alias -Name "l" -Value "${env:ProgramFiles(x86)}\Git\bin\less.exe"
Look for less
either in the above path or C:\Program Files\Git\usr\bin\less.exe
or similar.
*: I had errors in Powershell with the Gow version of "less".

- 65
- 7

- 2,142
- 2
- 23
- 20
-
2Me too. Besides paging backwards, less allows me to perform text search on the result (forward slash, then type text, then press enter, then 'n' for next result, 'p' for previous result). Very, very, convenient. – Rui Craveiro Feb 22 '19 at 09:47
-
Another `less` fan here. But I get this error. Any advice? ________________________________________ ```PS C:\Users\oli> Get-Content tmpf | out-host 'C:\Program Files\Git\usr\bin\less.exe' Out-Host : A positional parameter cannot be found that accepts argument 'C:\Program Files\Git\usr\bin\less.exe'. At line:1 char:20 + Get-Content tmpf | out-host 'C:\Program Files\Git\usr\bin\less.exe' + CategoryInfo : InvalidArgument: (:) [Out-Host], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.OutHostCommand``` – olisteadman Jul 24 '19 at 13:30
-
@olisteadman, This is the official Git version of less.exe. Have you tried the Git for Windows https://gitforwindows.org/ version of less? – Josh Jan 10 '20 at 17:08
-
No need to use "out-host". I use this: "Get-Content tmpf | C:\cygwin64\bin\less.exe" – Constantino Cronemberger Mar 08 '20 at 11:21
-
3It is also a very good idea to set $env:PAGER="C:\cygwin64\bin\less.exe", so it will be used for example when you type "help" – Constantino Cronemberger Mar 08 '20 at 11:44
-
-
In my 2018 installation, the folder is `...\Git\usr\bin`. I added the folder to my PATH and got hundreds of Linux commands in my PS. – TigerhawkT3 Aug 17 '23 at 03:36
PS> cd C:\
PS> dir -r -ex 0 | out-Host -paging
PS> dir -file -r -ea 0 c:\Windows | Select FullName,Length,LastWriteTime | out-gridview

- 5,987
- 2
- 39
- 61
more
isn't used to limit output, it's used to paginate output and make it easier to read in a terminal, if anything.
Are you talking about using head
and tail
? EggHeadCafe has an example of:
type my.txt | select-object -first 10
type my.txt | select-object -last 10
to emulate head
and tail
.

- 249,864
- 45
- 407
- 398
-
Piping is extremely slow for large files. There are better ways (built-in options) to do `head` and `tail` in powershell now: http://stackoverflow.com/a/41626586/1081043 – wisbucky Jan 13 '17 at 03:01
-
Note that this only works if your default WSL distribution is WSL1. WSL2 distributions run into the problem mentioned in [these](https://github.com/microsoft/WSL/issues/4754) [two](https://github.com/microsoft/WSL/issues/4646) Github issues. It's also possible to specify a WSL1 distribution manually in the command-line with `-d
`. – NotTheDr01ds Aug 08 '22 at 23:15
If you have VIM installed, I thoroughly enjoy dir -r | vim -R -
. Unfortunately this suffers the same problem with more
(ie. no streaming).

- 1,847
- 23
- 19
cat C:\Temp\test.txt
cat is an alias for Get-Content - with larger files you will get the -- More -- output at the bottom of the terminal
You can also you can add -wait
cat C:\Temp\test.txt -wait
-wait is like using tail but it actually is rerunning the command just refreshing the output
cat C:\Temp\test.txt | oh –Paging
oh = Out-Host

- 21
- 2
I added a function definition and alias to my default profile at
%SystemRoot%\system32\windowspowershell\v1.0\profile.ps1
This function is mostly based on this blog entry by Aman Dhally with added exception handling for pressing Q
while paging.
function more2
{
param(
[Parameter(ValueFromPipeline=$true)]
[System.Management.Automation.PSObject]$InputObject
)
begin
{
$type = [System.Management.Automation.CommandTypes]::Cmdlet
$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(‘Out-Host’, $type)
$scriptCmd = {& $wrappedCmd @PSBoundParameters -Paging }
$steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin)
$steppablePipeline.Begin($PSCmdlet)
}
process
{
try
{
$steppablePipeline.Process($_)
}
catch
{
break;
}
}
end
{
$steppablePipeline.End()
}
#.ForwardHelpTargetName Out-Host
#.ForwardHelpCategory Cmdlet
}
New-Alias more more2
so I can just call it like dir -r | more
and it immediately starts paged output because of PowerShell's pipeline (as opposed to waiting for the complete output with more.com).
I had exactly this question (well I wanted less, not more) and found the answer of @richard-berg worked for me, being new to PowerShell (but not to Linux), I found the things missing from that answer (for me) were:
I first needed to go:
Find-Package pscx | Install-Package
which then prompted for "installing nuget package". I did this but then had to use the -AllowClobber
parameter on Install-Package
.
then in order to use less, I had to:
Set-ExecutionPolicy RemoteSigned
which all worked :-)

- 482
- 1
- 9
- 14
-
Welcome to the site. Not sure what you mean by "answer #24". Those numbers are votes (which can change) rather than enumeration. – mhhollomon Mar 22 '19 at 18:06
-
Ah, I see ... first time I've posted to stack overflow! I meant the answer of @richard-berg, for me, that would have been the accepted answer – Bill Naylor Mar 22 '19 at 19:11
-
Not sure why I get a down vote? Seems (to me) it is helpful to confirm when something has worked! – Bill Naylor Dec 07 '19 at 10:56
Suggestion: Put the file into a temporary/disposable .txt file, then let the OS invoke your favorite editor, the one that is linked to the .txt extension.
Get-Process | Out-File temp.txt ; .\temp.txt
Note: each time you use this you will overwrite any pre-existent temp.txt file. Pick the file name wisely.
The above is just a basic idea.
Next step would be transforming this into "| more" using aliases or profile functions, etc.
HTH, Marcelo Finkielsztein

- 140
- 2
- 8
The easiest/most elegant in-built way of paging output without relying on non-standard utilities is to pipe the output through the Out-Host
utility. Usually, all output goes through this utility by default but, if manually specified, you can add the -Paging
option that provides similar functionality to less
or more
under Unix-based OS:
Get-Content a_very_long_file.txt | Out-Host -Paging
PowerShell has many predefined aliases. In this case, this can be shortened to:
gc a_very_long_file.txt | oh -P
which means exactly the same (gc
== Get-Content
; oh
== Output-Host
)
To read more about the Out-Host
utility:
Get-Help Out-Host

- 1,597
- 1
- 14
- 29