From 06320ab4199141899c3d5984d727d36c496f9c3a Mon Sep 17 00:00:00 2001 From: Simon Heather Date: Mon, 8 Jun 2020 20:04:36 +0100 Subject: [PATCH 1/4] Disable Progress bar for Invoke-WebRequest --- GitHubCore.ps1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/GitHubCore.ps1 b/GitHubCore.ps1 index a324a5bb..ca19c5cf 100644 --- a/GitHubCore.ps1 +++ b/GitHubCore.ps1 @@ -223,8 +223,15 @@ function Invoke-GHRestMethod } } + # Temporarily Disable Progress Bar during Invoke-WebRequest + $tempProgressPreference = $ProgressPreference + $ProgressPreference = 'SilentlyContinue' + [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12 $result = Invoke-WebRequest @params + + $progressPreference = $tempProgressPreference + if ($Method -eq 'Delete') { Write-Log -Message "Successfully removed." -Level Verbose @@ -265,8 +272,14 @@ function Invoke-GHRestMethod try { + # Temporarily Disable Progress Bar during Invoke-WebRequest + $tempProgressPreference = $ProgressPreference + $ProgressPreference = 'SilentlyContinue' + [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12 Invoke-WebRequest @params + + $progressPreference = $tempProgressPreference } catch [System.Net.WebException] { From 5d97f8b58350aa612633cd24aa961639dd063543 Mon Sep 17 00:00:00 2001 From: Simon Heather Date: Tue, 9 Jun 2020 20:51:10 +0100 Subject: [PATCH 2/4] Remove saving/restoring of ProgressPreference --- GitHubCore.ps1 | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/GitHubCore.ps1 b/GitHubCore.ps1 index ca19c5cf..d9605abd 100644 --- a/GitHubCore.ps1 +++ b/GitHubCore.ps1 @@ -223,15 +223,12 @@ function Invoke-GHRestMethod } } - # Temporarily Disable Progress Bar during Invoke-WebRequest - $tempProgressPreference = $ProgressPreference + # Disable Progress Bar during Invoke-WebRequest $ProgressPreference = 'SilentlyContinue' [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12 $result = Invoke-WebRequest @params - $progressPreference = $tempProgressPreference - if ($Method -eq 'Delete') { Write-Log -Message "Successfully removed." -Level Verbose @@ -272,14 +269,11 @@ function Invoke-GHRestMethod try { - # Temporarily Disable Progress Bar during Invoke-WebRequest - $tempProgressPreference = $ProgressPreference + # Disable Progress Bar during Invoke-WebRequest $ProgressPreference = 'SilentlyContinue' [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12 Invoke-WebRequest @params - - $progressPreference = $tempProgressPreference } catch [System.Net.WebException] { From 356a0250feb879717711a051e77c8a069f4fc375 Mon Sep 17 00:00:00 2001 From: Simon Heather Date: Tue, 9 Jun 2020 23:23:59 +0100 Subject: [PATCH 3/4] Update Progress Bar disable comment --- GitHubCore.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GitHubCore.ps1 b/GitHubCore.ps1 index d9605abd..865cdc3d 100644 --- a/GitHubCore.ps1 +++ b/GitHubCore.ps1 @@ -223,7 +223,7 @@ function Invoke-GHRestMethod } } - # Disable Progress Bar during Invoke-WebRequest + # Disable Progress Bar in function scope during Invoke-WebRequest $ProgressPreference = 'SilentlyContinue' [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12 @@ -269,7 +269,7 @@ function Invoke-GHRestMethod try { - # Disable Progress Bar during Invoke-WebRequest + # Disable Progress Bar in function scope during Invoke-WebRequest $ProgressPreference = 'SilentlyContinue' [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12 From 85d6bc7bf544ca91c77731e7770060f1fc007b67 Mon Sep 17 00:00:00 2001 From: Simon Heather Date: Tue, 9 Jun 2020 23:24:13 +0100 Subject: [PATCH 4/4] Add progress bar disable --- Telemetry.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Telemetry.ps1 b/Telemetry.ps1 index 02296ae2..16efb7c5 100644 --- a/Telemetry.ps1 +++ b/Telemetry.ps1 @@ -181,6 +181,9 @@ function Invoke-SendTelemetryEvent $params.Add("TimeoutSec", (Get-GitHubConfiguration -Name WebRequestTimeoutSec)) $params.Add("Body", $bodyAsBytes) + # Disable Progress Bar in function scope during Invoke-WebRequest + $ProgressPreference = 'SilentlyContinue' + $result = Invoke-WebRequest @params } } @@ -211,6 +214,9 @@ function Invoke-SendTelemetryEvent try { + # Disable Progress Bar in function scope during Invoke-WebRequest + $ProgressPreference = 'SilentlyContinue' + Invoke-WebRequest @params } catch [System.Net.WebException]