首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >隐藏Invoke-WebRequest的进度

隐藏Invoke-WebRequest的进度
EN

Stack Overflow用户
提问于 2013-09-13 01:30:35
回答 1查看 38.8K关注 0票数 71

如何隐藏Invoke-WebRequest的进度显示?我做了很多连续的请求,并且有我自己使用的Write-Progress显示器,所以我不需要每次都在它下面弹出内置的一个。

我使用从Invoke-WebRequest的结果自动创建的mshtml结果( IE对象),因此我不能切换到WebClient或类似的东西,除非有人提供如何从WebClient请求中获取mshtml对象的说明。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-13 01:35:12

使用$progressPreference变量。默认情况下,它的值应该是'Continue‘,除非您在其他地方对其进行了编辑,这会告诉Powershell显示进度条。由于您提到您有自己的自定义进度显示,因此我将在执行cmdlet后立即重置它。例如:

代码语言:javascript
复制
$ProgressPreference = 'SilentlyContinue'    # Subsequent calls do not display UI.
Invoke-WebRequest ...
$ProgressPreference = 'Continue'            # Subsequent calls do display UI.
Write-Progress ...

有关偏好变量的更多信息,请访问about_preference_variables。下面是$ProgressPreference的条目:

代码语言:javascript
复制
$ProgressPreference
-------------------
Determines how Windows PowerShell responds to progress updates 
        generated by a script, cmdlet or provider, such as the progress bars
        generated by the Write-Progress cmdlet. The Write-Progress cmdlet 
        creates progress bars that depict the status of a command.

        Valid values:
          Stop:               Does not display the progress bar. Instead,
                                it displays an error message and stops executing.

          Inquire:            Does not display the progress bar. Prompts
                                for permission to continue. If you reply
                                with Y or A, it displays the progress bar.

          Continue:           Displays the progress bar and continues with
          (Default)             execution.

          SilentlyContinue:   Executes the command, but does not display
                                the progress bar.
票数 104
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18770723

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档