-all option for get-asset, returns all results

This commit is contained in:
Petri Asikainen 2021-01-18 11:06:10 +02:00
parent a09eb8c23e
commit 1b12288920

View file

@ -14,6 +14,9 @@ Specify exact asset tag to query
.PARAMETER asset_serial .PARAMETER asset_serial
Specify exact asset serial to query Specify exact asset serial to query
.PARAMETER all
A return all results , works with -search and other filters
.PARAMETER order_number .PARAMETER order_number
Optionally restrict asset results to this order number Optionally restrict asset results to this order number
@ -78,6 +81,8 @@ function Get-Asset() {
[string]$asset_serial, [string]$asset_serial,
[bool]$all = $false,
[int]$order_number, [int]$order_number,
[int]$model_id, [int]$model_id,
@ -151,12 +156,30 @@ function Get-Asset() {
Token = $apiKey Token = $apiKey
} }
$result = Invoke-SnipeitMethod @Parameters if($all) {
$offstart = $(if($offset){$offset} Else {0})
$callargs = $SearchParameter
$callargs.Remove('all')
while($true) {
$callargs['offset'] = $offstart
$callargs['limit'] = $limit
$res=Get-Asset @callargs
$res
if( $res.count -lt $limit) {
break
}
$offstart = $offstart + $limit
}
} else {
$result = Invoke-SnipeitMethod @Parameters
$result $result
} }
}