mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 18:02:30 +00:00
-all option for get-asset, returns all results
This commit is contained in:
parent
a09eb8c23e
commit
1b12288920
1 changed files with 40 additions and 17 deletions
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue