This is a small function that emulates the behaviour of the old DOS command ‘more’. The only caveat is that it doesn’t work when running under ISE.

function Get-ContentPaginated {
    [CmdletBinding()]
    param(
        [Parameter(Position = 0, Mandatory)]
        $InputObject
    )
    if ($host.Name -eq 'ConsoleHost') {
        try {
            Get-Content $InputObject | Out-Host -Paging
        }

        catch {
        }
    }
    
    else {
        Write-Warning 'This function only works in the console host.'
    }
}

New-Alias -Name more -Value Get-ContentPaginated

Add the code to your PowerShell profile, and run it like this:

more .\longtextfile.txt

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s