如何隐藏进度显示Invoke-WebRequest
?我连续提出了很多请求,并有自己的请求Write-Progress
我使用的显示器,所以我不需要每次都在它下面弹出内置的显示器。
我使用从结果创建的 mshtml 结果(IE COM 对象)Invoke-WebRequest
自动,所以我无法切换到WebClient
或类似的东西,除非有人提供有关如何从 WebClient 请求获取 mshtml 对象的说明。
使用 $progressPreference 变量。默认情况下,它的值应为“继续”,除非您在其他地方对其进行了编辑,这会告诉 Powershell 显示进度条。由于您提到您有自己的自定义进度显示,因此我会在执行 cmdlet 后立即重置它。例如:
$ProgressPreference = 'SilentlyContinue' # Subsequent calls do not display UI.
Invoke-WebRequest ...
$ProgressPreference = 'Continue' # Subsequent calls do display UI.
Write-Progress ...
有关偏好变量的更多信息,请访问about_preference_variables http://technet.microsoft.com/en-us/library/hh847796.aspx。这是 $ProgressPreference 的条目:
$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.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)