powershellfunctionpagination

Powershell Out-Host -paging -or- more to limit output of function


I have made a function that gives users instructions. When I call it I would like to have only 1 page (screen) of info appear at a time.

I've tried using

function1 | Out-Host -paging

and

function1 | more

But neither of them work. The function is a bunch of Write-Hosts. Do I need to define something within the function?


Solution

  • Out-Host expects a stream of objects and write-host does not do that. It simply writes to the console. Instead, use Write-Output and then try Out-Host -Paging.