Powershell Clear-Host alternative to preserve the buffer

不羁岁月 提交于 2019-12-07 07:51:18

问题


I would like something like Clear-Host, but would like the scrollback.

So far, all I have is basically adding newlines until the screen is clear. Though when I do this, the cursor starts writing at the bottom of the page (as to be expect- though not desired).

I would hope to start writing at the top of the page (for menus and such- which is the natural thing to do)

This is the code to print the dynamic count of new lines:

do {Write-Host ""; $i++}
while ($i -ne $Host.UI.RawUI.WindowSize.Height)

I did see something about a Transcript module, but do not desire that.

Thanks in advance.


回答1:


Here's a post which gives exactly what you're looking for:

http://tommymaynard.com/ql-clear-host-without-clearning-the-host/



来源:https://stackoverflow.com/questions/27001404/powershell-clear-host-alternative-to-preserve-the-buffer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!