PowerShell ISE

In the PowerShell console, you can pipe commands to the old-fashioned “more.com”, or better yet, to Out-Host –Paging. This will display data page by page, asking for a key press to continue:

 
PS> Get-Process | more
PS> Get-Process | Out-Host -Paging                                                    
 

In the PowerShell ISE, neither of these is supported. That’s because the ISE has no console, and there is no “visible line count”, just an unlimited text buffer.

To prevent large amounts of results to fly over your screen, simply create your own ISE-compatible “more”:

function Out-More
{
    param
    (
        $Lines = 10,
        
        [Parameter(ValueFromPipeline=$true)]
        $InputObject
    )
    
    begin
    {
        $counter = 0
    }
    
    process
    {
        $counter++
        if ($counter -ge $Lines)
        {
            $counter = 0
            Write-Host 'Press ENTER to continue' -ForegroundColor Yellow
            Read-Host  
        }
        $InputObject
    }
} 

Pipe your results into Out-More, and use –Lines to specify after how many result lines there should be a temporary output stop:

 
PS> Get-Process | Out-More -Lines 4

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName                                                                       
-------  ------    -----      ----- -----   ------     -- -----------                                                                       
    100       9     1436       1592    51            6896 adb                                                                               
    307      42    22332      12940   123            1424 AllShareFrameworkDMS                                                              
     42       4     1396       1284    19            1404 AllShareFrameworkManagerDMS                                                       
Press ENTER to continue  


     81       7     1004        724    43            1388 armsvc                                                                            
    202      25    50376      55320   234     8,06  13720 chrome                                                                            
   1131      65    68672      93892   361   116,73  13964 chrome                                                                            
    199      24    53008      52700   225     5,56  14768 chrome                                                                            
Press ENTER to continue  


    248      26    31348      44984   239    44,31  15404 chrome                                                                            
    173      20    23756      25540   179     1,27  16492 chrome                                                                            
    190      22    36316      39208   207     2,81  16508 chrome                                                                            
    184      23    41800      44212   223     1,77  17244 chrome                                                                            
Press ENTER to continue                                                      
 

Twitter This Tip! ReTweet this Tip!

Anonymous