Skip to content

PowerShellForGitHub: Suggest Disabling ProgressBar when Calling Invoke-WebRequest #227

Closed
@X-Guardian

Description

@X-Guardian

Issue Details

It is a known issue that the speed of Invoke-WebRequest is affected badly by displaying the progress bar, especially for larger transfers in PowerShell 5. See Progress bar can significantly impact cmdlet performance.

It is suggested to disable the progress bar for Invoke-WebRequest to improve the speed of the Pester tests and also general module performance. This would also remove progress bar 'flickering' when using NoStatus.

Steps to reproduce the issue

(Measure-Command { Invoke-Pester .\Tests\GitHubRepositories.tests.ps1 -Show None}).TotalSeconds

Results

PowerShell Version Progress Bar State Run Time in Seconds
5.1 Enabled 62
5.1 Disabled 52
7.0.1 Enabled 56
7.0.1 Disabled 57

Suggested solution to the issue

Add the following lines before both Invoke-WebRequest calls in the Invoke-GHRestMethod function:

$tempProgressPreference = $ProgressPreference
$ProgressPreference = 'SilentlyContinue'

and the following line after both calls:

$progressPreference = $tempProgressPreference

This change has no affect on the Status progress bar.

Requested Assignment

  • If possible, I would like to fix this.

Operating System

OsName               : Microsoft Windows 10 Pro
OsOperatingSystemSKU : 48
OsArchitecture       : 64-bit
WindowsVersion       : 1903
WindowsBuildLabEx    : 18362.1.amd64fre.19h1_release.190318-1202
OsLanguage           : en-GB
OsMuiLanguages       : {en-GB, en-US, th-TH}

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.0.1
PSEdition                      Core
GitCommitId                    7.0.1
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module Version

Running: 0.14.0
Installed: 0.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis relates to a bug in the existing module.in progressWork on this issue is already underway. Please don't work start new work on it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions