Skip to content

Commit 5e21f0b

Browse files
Invoke-ADORestAPI: Improving performance of -AsByte (fixes #114)
1 parent fd32436 commit 5e21f0b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Invoke-ADORestAPI.ps1

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ $($MyInvocation.MyCommand.Name) @parameter
397397
if ($AsByte) {
398398
$ms = [IO.MemoryStream]::new()
399399
$rs.CopyTo($ms)
400-
$ms.ToArray()
400+
,$ms.ToArray()
401401
$ms.Dispose()
402402
return
403403
}
@@ -419,6 +419,9 @@ $($MyInvocation.MyCommand.Name) @parameter
419419
$null = $null
420420
# We call Invoke-RestMethod with the parameters we've passed in.
421421
# It will take care of converting the results from JSON.
422+
if ($response -is [byte[]]) {
423+
return $response
424+
}
422425

423426
$apiOutput =
424427
$response |
@@ -429,7 +432,7 @@ $($MyInvocation.MyCommand.Name) @parameter
429432
# A lot of things in the Azure DevOps REST apis come back as a count/value pair
430433
if ($in -eq 'null') {
431434
return
432-
}
435+
}
433436
if ($ExpandProperty) {
434437
if ($in.$ExpandProperty) {
435438
return $in.$ExpandProperty
@@ -451,7 +454,7 @@ $($MyInvocation.MyCommand.Name) @parameter
451454

452455

453456
$in = $_
454-
if ($in -is [string]) { return $in }
457+
if ($in -is [string]) { return $in }
455458
if ($null -ne $in.Count -and $in.Count -eq 0) {
456459
return
457460
}

0 commit comments

Comments
 (0)