How do you hide a Powershell progress message?

2019-02-12 09:34发布

I think Write-Progress is a rather beautiful Cmdlet. In fact Sharepoint makes use of it with its Start-SPAdminJob commandlet.

All fine and dandy, the problem is that Start-SPAdminJob does not correctly "dispose" of the Write-Progress dialog. It is never set to 100 percent complete which means it just stays in the Powershell dialog until you exit the script - this in turn hides part of the messages underneath the "progress window".

Is there any way I can force an existing Write-Progress to "exit" or be set to 100% complete? Any way how I could find out the ID of the progress the Start-SPAdminJob cmdlet is using - that way I could manually set the percentage.

2条回答
太酷不给撩
2楼-- · 2019-02-12 10:10

This code forces progress bar to be set to 100% complete and hides it:

Write-Progress "Done" "Done" -completed
查看更多
虎瘦雄心在
3楼-- · 2019-02-12 10:14

You could stop the progress bar appearing in the first place by doing the following beforehand:

$ProgressPreference = "SilentlyContinue";

You could then restore the preference to "Continue" afterwards. Not much help if you actually want the bar of course...

查看更多
登录 后发表回答