PowerShell 帮助文件未正确显示 [英] PowerShell helpfiles not displaying correctly
问题描述
在 Windows 10 和 Windows Server 2012 上的 PowerShell 4.0、5.0 中测试:
Tested in PowerShell 4.0, 5.0 on Windows 10 and Windows Server 2012:
clear
help *-wmiobject*
或
cls
man *-job*
帮助文件在清屏后无法正确显示结果.重新运行命令,它按预期工作.
The help file does not display results correctly after clearing screen. Re-run the command and it works as expected.
Get-Help is unaffected.
这是什么原因?
谢谢
推荐答案
一个有趣的错误.原因(显然)是在 Powershell 显示 help()
调用的结果后更新了搜索帮助"的进度条,有效地清除了第 2 行到第 9 行的 8 行最佳.解决方法是将结果存储在一个临时变量中.
A funny bug. The reason (apparently) is that the progress bar for "Searching for help" is updated after Powershell displays the results of help()
call, effectively clearing the 8 rows from row #2 to #9 from the top. The workaround is store the result in a temporary variable.
$temp=help *-wmiobject; $temp
这确保函数在显示内容之前已经退出,因此进度条已经从窗口中移除.
This ensures that the function has exited before displaying stuff, thus the progress bar will already be removed from the window.
更新:如果您在 help
的参数中不包含星号,则该错误不存在.因此,可能会出现这个bug,因为显示是在help()
的Process"部分完成的,清除进度条的代码位于函数的End"部分.
UPDATE: The bug isn't present if you do not include the asterisks in the argument to help
. Therefore, the bug might arise because the displaying is done in the "Process" part of help()
, and the code that clears the progress bar is located in the "End" part of the function.
这篇关于PowerShell 帮助文件未正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!