Skip to content

Commit 6e794cb

Browse files
authored
PowerShellForGitHub: Disable Progress Bar for Invoke-WebRequest (#229)
Disables the PowerShell progress bar for the `Invoke-WebRequest` cmdlet calls in the `Invoke-GHRestMethod` and `Invoke-SendTelemetryEvent` functions due to known performance issues in PowerShell 5.1. Reference: [Progress bar can significantly impact cmdlet performance.](PowerShell/PowerShell#2138) Fixes #227
1 parent 3c642d2 commit 6e794cb

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

GitHubCore.ps1

+7
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,12 @@ function Invoke-GHRestMethod
223223
}
224224
}
225225

226+
# Disable Progress Bar in function scope during Invoke-WebRequest
227+
$ProgressPreference = 'SilentlyContinue'
228+
226229
[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12
227230
$result = Invoke-WebRequest @params
231+
228232
if ($Method -eq 'Delete')
229233
{
230234
Write-Log -Message "Successfully removed." -Level Verbose
@@ -265,6 +269,9 @@ function Invoke-GHRestMethod
265269

266270
try
267271
{
272+
# Disable Progress Bar in function scope during Invoke-WebRequest
273+
$ProgressPreference = 'SilentlyContinue'
274+
268275
[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12
269276
Invoke-WebRequest @params
270277
}

Telemetry.ps1

+6
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ function Invoke-SendTelemetryEvent
181181
$params.Add("TimeoutSec", (Get-GitHubConfiguration -Name WebRequestTimeoutSec))
182182
$params.Add("Body", $bodyAsBytes)
183183

184+
# Disable Progress Bar in function scope during Invoke-WebRequest
185+
$ProgressPreference = 'SilentlyContinue'
186+
184187
$result = Invoke-WebRequest @params
185188
}
186189
}
@@ -211,6 +214,9 @@ function Invoke-SendTelemetryEvent
211214

212215
try
213216
{
217+
# Disable Progress Bar in function scope during Invoke-WebRequest
218+
$ProgressPreference = 'SilentlyContinue'
219+
214220
Invoke-WebRequest @params
215221
}
216222
catch [System.Net.WebException]

0 commit comments

Comments
 (0)