Out-Host -Paging错误“未实现方法或操作。 ”

问题描述 投票:1回答:2

我执行这个Powershell命令:

Get-Process | Out-Host -Paging

但它给我的错误:

ut-lineoutput:未实现方法或操作。在行:1 char:1 + Get-Process | Out-Host -Paging + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:NotSpecified :( :) [out-lineoutput], NotImplementedException + FullyQualifiedErrorId:System.NotImplementedException,Microsoft.PowerShell.Commands.OutLineOutputCommand

我已经检查了Out-host的帮助,并且通过分页,它应该逐页返回结果。

基本上我想逐页查看结果而不是一切都刷新。请帮忙

powershell powershell-ise
2个回答
3
投票

-Paging旗帜不适用于powershell_ise.exe

使用powershell.exe

另一个选择虽然它可能不完全是你需要的......

$file="c:\temp\out.txt"
dir -Recurse | Out-File $file
notepad $file

0
投票

分页,你可以做到这一点......

$page = 20
$step = $page
$command = get-process
$count = $command.count
while ($count -gt ($page - $step)){
    $command[($page - $step)..$page]
    Pause
    $page += $step + 1
}

只需将$ page设置为您希望每页显示的内容...它实际上比您想要的多1个,因为您从0开始不是1.因此每页显示21个。

有人把它变成了一个模块,所以你可以这样做...... http://community.idera.com/powershell/powertips/b/tips/posts/using-more-in-the-powershell-ise

他的脚本基本上单独读取每一行,然后如果你点击你的计数器,它只是吐出“按回车继续”然后读取下一行等...

© www.soinside.com 2019 - 2024. All rights reserved.