You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Tools/SandboxTest.ps1
+42-10Lines changed: 42 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,11 @@ enum DependencySources {
48
48
$ProgressPreference='SilentlyContinue'
49
49
$ErrorActionPreference='Stop'# This gets overridden most places, but is set explicitly here to help catch errors
50
50
if ($PSBoundParameters.Keys-notcontains'InformationAction') { $InformationPreference='Continue' } # If the user didn't explicitly set an InformationAction, Override their preference
@@ -212,14 +219,27 @@ function Get-RemoteContent {
212
219
)
213
220
Write-Debug"Attempting to fetch content from $URL"
214
221
# Check if the URL is valid before trying to download
215
-
$response= [String]::IsNullOrWhiteSpace($URL) ?@{StatusCode=400 } : $(Invoke-WebRequest-Uri $URL-Method Head -ErrorAction SilentlyContinue) # If the URL is null, return a status code of 400
222
+
# If the URL is null, return a status code of 400
223
+
if ([String]::IsNullOrWhiteSpace($URL)) {
224
+
$response=@{ StatusCode=400 }
225
+
} else {
226
+
$response=Invoke-WebRequest-Uri $URL-Method Head -ErrorAction SilentlyContinue
227
+
}
216
228
if ($response.StatusCode-ne200) {
217
229
Write-Debug"Fetching remote content from $URL returned status code $($response.StatusCode)"
218
230
return$null
219
231
}
220
-
$localFile=$OutputPath? [System.IO.FileInfo]::new($OutputPath) : $(New-TemporaryFile) # If a path was specified, store it at that path; Otherwise use the temp folder
232
+
# If a path was specified, store it at that path; Otherwise use the temp folder
# If the download fails, write a zero-byte file anyways
229
249
$null|Out-File$localFile.FullName
230
250
}
231
-
return$Raw?$(Get-Content-Path $localFile.FullName) : $localFile# If the raw content was requested, return the content, otherwise, return the FileInfo object
251
+
# If the raw content was requested, return the content, otherwise, return the FileInfo object
252
+
if ($Raw) {
253
+
returnGet-Content-Path $localFile.FullName
254
+
} else {
255
+
return$localFile
256
+
}
232
257
}
233
258
234
259
####
@@ -491,17 +516,24 @@ if (!$SkipManifestValidation -and ![String]::IsNullOrWhiteSpace($Manifest)) {
491
516
}
492
517
switch ($LASTEXITCODE) {
493
518
'-1978335191' {
494
-
($validateCommandOutput|Select-Object-Skip 1-SkipLast 1) |Write-Information# Skip the first line and the empty last line
0 commit comments