@@ -89,7 +89,7 @@ $script:HostGeoID = (Get-WinHomeLocation).GeoID
89
89
90
90
# Misc
91
91
[Net.ServicePointManager ]::SecurityProtocol = [Net.SecurityProtocolType ]::Tls12
92
- $script :WebClient = New-Object System.Net.WebClient
92
+ $script :HttpClient = New-Object System.Net.Http.HttpClient
93
93
$script :CleanupPaths = @ ()
94
94
95
95
# The experimental features get updated later based on a switch that is set
@@ -114,7 +114,7 @@ function Invoke-CleanExit {
114
114
[int ] $ExitCode
115
115
)
116
116
Invoke-FileCleanup - FilePaths $script :CleanupPaths
117
- $script :WebClient .Dispose ()
117
+ $script :HttpClient .Dispose ()
118
118
Write-Debug " Exiting ($ExitCode )"
119
119
exit $ExitCode
120
120
}
@@ -186,7 +186,8 @@ function Get-RemoteContent {
186
186
Write-Debug " Remote content will be stored at $ ( $localFile.FullName ) "
187
187
$script :CleanupPaths += $Raw ? @ ($localFile.FullName ) : @ () # Mark the file for cleanup when the script ends if the raw data was requested
188
188
try {
189
- $script :WebClient.DownloadFile ($URL , $localFile.FullName )
189
+ $downloadTask = $script :HttpClient.GetByteArrayAsync ($URL )
190
+ [System.IO.File ]::WriteAllBytes($localfile.FullName , $downloadTask.Result )
190
191
}
191
192
catch {
192
193
# If the download fails, write a zero-byte file anyways
@@ -295,7 +296,7 @@ if (!$SkipManifestValidation -and ![String]::IsNullOrWhiteSpace($Manifest)) {
295
296
Invoke-CleanExit - ExitCode 3
296
297
}
297
298
Write-Information " --> Validating Manifest"
298
- $validateCommandOutput =
299
+ $validateCommandOutput =
299
300
& {
300
301
# Store current output encoding setting
301
302
$prevOutEnc = [Console ]::OutputEncoding
@@ -306,7 +307,7 @@ if (!$SkipManifestValidation -and ![String]::IsNullOrWhiteSpace($Manifest)) {
306
307
307
308
# Reset the encoding to the previous values
308
309
[Console ]::OutputEncoding = $prevOutEnc
309
- }
310
+ }
310
311
switch ($LASTEXITCODE ) {
311
312
' -1978335191' {
312
313
($validateCommandOutput | Select-Object - Skip 1 - SkipLast 1 ) | Write-Information # Skip the first line and the empty last line
0 commit comments