Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Tools/SandboxTest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ $script:HostGeoID = (Get-WinHomeLocation).GeoID

# Misc
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$script:WebClient = New-Object System.Net.WebClient
$script:HttpClient = New-Object System.Net.Http.HttpClient
$script:CleanupPaths = @()

# The experimental features get updated later based on a switch that is set
Expand All @@ -114,7 +114,7 @@ function Invoke-CleanExit {
[int] $ExitCode
)
Invoke-FileCleanup -FilePaths $script:CleanupPaths
$script:WebClient.Dispose()
$script:HttpClient.Dispose()
Write-Debug "Exiting ($ExitCode)"
exit $ExitCode
}
Expand Down Expand Up @@ -186,7 +186,8 @@ function Get-RemoteContent {
Write-Debug "Remote content will be stored at $($localFile.FullName)"
$script:CleanupPaths += $Raw ? @($localFile.FullName) : @() # Mark the file for cleanup when the script ends if the raw data was requested
try {
$script:WebClient.DownloadFile($URL, $localFile.FullName)
$downloadTask = $script:HttpClient.GetByteArrayAsync($URL)
[System.IO.File]::WriteAllBytes($localfile.FullName, $downloadTask.Result)
}
catch {
# If the download fails, write a zero-byte file anyways
Expand Down Expand Up @@ -295,7 +296,7 @@ if (!$SkipManifestValidation -and ![String]::IsNullOrWhiteSpace($Manifest)) {
Invoke-CleanExit -ExitCode 3
}
Write-Information "--> Validating Manifest"
$validateCommandOutput =
$validateCommandOutput =
& {
# Store current output encoding setting
$prevOutEnc = [Console]::OutputEncoding
Expand All @@ -306,7 +307,7 @@ if (!$SkipManifestValidation -and ![String]::IsNullOrWhiteSpace($Manifest)) {

# Reset the encoding to the previous values
[Console]::OutputEncoding = $prevOutEnc
}
}
switch ($LASTEXITCODE) {
'-1978335191' {
($validateCommandOutput | Select-Object -Skip 1 -SkipLast 1) | Write-Information # Skip the first line and the empty last line
Expand Down