PowerShell进度条不会消失

时间:2018-04-05 19:21:25

标签: powershell

我的脚本中的一些PowerShell命令使用进度条,并且在命令完成后很长时间内这些进度条会一直挂起。如何让它们消失?

例如,将以下三行保存为.ps1脚本,然后从命令行运行它。当窗口从目录列表中滚动时,完成命令中进度条的重影图像会闪烁。

$ready = Read-Host "Press Return to Start. Press Control-C anytime to exit."
Test-NetConnection localhost
if ($?) { dir -Path C:\Windows -Recurse -File }

Picture of the ghost progress bar

我需要在Test-NetConnection命令和dir命令之间添加什么才能使鬼进度条消失?

1 个答案:

答案 0 :(得分:1)

似乎有所帮助:

$ready = Read-Host "Press Return to Start. Press Control-C anytime to exit."
Test-NetConnection localhost
Write-Progress -Completed -Activity "make progress bar dissapear"
if ($?) { dir -Path C:\Windows -Recurse -File }
相关问题