如何隐藏 Powershell 进度消息? [英] How do you hide a Powershell progress message?

查看:58
本文介绍了如何隐藏 Powershell 进度消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为 Write-Progress 是一个相当漂亮的 Cmdlet.事实上,Sharepoint 使用它的 Start-SPAdminJob commandlet.

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

一切正常,问题是 Start-SPAdminJob 没有正确处理"Write-Progress 对话框.它永远不会设置为 100% 完成,这意味着它只会停留在 Powershell 对话框中,直到您退出脚本 - 这反过来隐藏了进度窗口"下方的部分消息.

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".

有什么方法可以强制现有的 Write-Progress退出"或设置为 100% 完成?以任何方式找出 Start-SPAdminJob cmdlet 正在使用的进度 ID - 这样我就可以手动设置百分比.

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.

推荐答案

您可以通过预先执行以下操作来首先停止显示进度条:

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...

这篇关于如何隐藏 Powershell 进度消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆