In a PowerShell console, you can continue to pipe to more, just like in cmd.exe, to view results page by page. However, more does not support real-time pipelining, so all data needs to be collected first. This can take a long time and burn much memory:

dir c:\windows -Recurse -ea 0  | more

A better way is to use PowerShell’s own paging mechanism:

dir c:\windows -Recurse -ea 0  | Out-Host -Paging

Note that this all requires a true console window. It won’t work in graphical hosts.

Twitter This Tip! ReTweet this Tip!

Anonymous
  • That blanket statement of not working in a GUI, is well, you know...not necessarily valid, because, actually, Visual Studio Code, is a GUI of sorts and will handle this just fine. Since it has a true PoSH console host / terminal.

    You can do this in the VSC script /Dev pane and it just outputs to the VSC PoSH console / terminal, or just do it in the VSC PoSH console / terminal directly.

    *note:*

    I'd love to see VSC replace the ISE and notepad holistically across Windows and not that it is cross platform, even more reason to do so.

    IMHO, but, hey, I am just some random guy. 8^}

    It does all the PoSH console host and PoSH ISE does and more.

    Well, except the very convenient Commands Tab in the ISE is not in VSC. If they could bring that commands tab to VSC, I'd be able to stop using the PoSH ISE altogether.

    Yes, I know you can just type Show-Command, but that is not the same thing (since it is model dialog and block any action ) as what ISE provides. Easy, view scroll / filter to selection, click to get properties options, click to run, click to copy, click to insert all live while work. With VSC you have to do all you want, copy, then close the dialog to run anything, then have to rinse and repeat when you need it again. Using that panel is far easier and more convenient via the ISE and less carpel tunnel inducing.

    *note:*

    Start-Process "$PSHOME\powershell.exe" -ArgumentList "-NoExit","-Command  &{ dir c:\windows -Recurse -ea 0  | Out-Host -Paging }"

    # I did the following to make this more usefull when I absolutely needed / had been required to use and interactive console commnad (console, cmd).

    # 1 - Turned it into a function

    Function Start-ConsoleCommand ($ConsoleCommand = ( Read-Host -Prompt 'Enter a console command with any needed switches' ))

    {

       Start-Process "$PSHOME\powershell.exe" -ArgumentList "-NoExit","-Command  &{ $ConsoleCommand }"

    }

    # 2 - created an alais for it

    # Set-Alias scc Start-ConsoleCommand

    and added 1 & 2 to my profile

    # 3 - as well as created a snippet for it so I can pop it into my code blocks as needed.

    Start Console Command.snippets.ps1xml

    <?xml version='1.0' encoding='utf-8' ?>

       <Snippets  xmlns='schemas.microsoft.com/.../Snippets'>

           <Snippet Version='1.0.0'>

               <Header>

                   <Title>Start Console Command</Title>

                   <Description>Used to start a console command entry shell out to the PowerShell Console</Description>

                   <Author></Author>

                   <SnippetTypes>

                       <SnippetType>Expansion</SnippetType>

                   </SnippetTypes>

               </Header>

               <Code>

                   <Script Language='PowerShell' CaretOffset='0'>

                       <![CDATA[Start-Process "$PSHOME\powershell.exe" `

    -ArgumentList "-NoExit","-Command  &{ Enter a console command with any needed switches }"]]>

                   </Script>

               </Code>

       </Snippet>

    </Snippets>

    # So, in my ISE sessions, I just do,,,

    # by itself, you will be prompted to enter a console command in the ISE console

    scc

    Enter a console command with any needed switches:

    # or using a command inline

    scc -ConsoleCommand dir c:\windows -Recurse -ea 0  | Out-Host -Paging

    # or

    scc dir c:\windows -Recurse -ea 0  | Out-Host -Paging

    All of the above will pop open the PoSH console host will leaving ISE as is. Once you are done with the console host, just close it and you are back to only using the ISE.

    Oh yea, but be sure to copy any output for later use as needed before closing the PoSH console.

    It works for me based on the way I try to stay in open tool at a time.

    I working to spend more time in VSC (especially with the improvements in each release), but my ISE is configured just as I like it, well, with additional add-ons. 8^}