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