From 2925106297aff15f91568af09facedf6e4e9b8d3 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Sun, 17 Jan 2021 05:42:25 +0200 Subject: [PATCH] Get-asset by serial --- SnipeitPS/Public/Get-Asset.ps1 | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/SnipeitPS/Public/Get-Asset.ps1 b/SnipeitPS/Public/Get-Asset.ps1 index b266e4b..cbcff27 100644 --- a/SnipeitPS/Public/Get-Asset.ps1 +++ b/SnipeitPS/Public/Get-Asset.ps1 @@ -8,6 +8,9 @@ A text string to search the assets data .PARAMETER asset_tag Specify exact asset tag to query +.PARAMETER asset_serial +Specify exact asset serial to query + .PARAMETER order_number Optionally restrict asset results to this order number @@ -68,6 +71,8 @@ function Get-Asset() { [string]$asset_tag, + [string]$asset_serial, + [int]$order_number, [int]$model_id, @@ -106,15 +111,27 @@ function Get-Asset() { $SearchParameter = . Get-ParameterValue + $apiuri = "$url/api/v1/hardware" + if ($search -and ($asset_tag -or $asset_serial)) { + Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search , -asset_tag or -asset_serial parameter , not both " + } + if ($asset_tag) { - if ( $search) { - Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search or -asset_tag parameter , not both " + if ( $search -or $asset_serial) { + Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search , -asset_tag or -asset_serial parameter , not both " } $apiuri= "$url/api/v1/hardware/bytag/$asset_tag" } + if ($asset_serial) { + if ( $search -or $asset_tag) { + Throw "[$($MyInvocation.MyCommand.Name)] Please specify only -search , -asset_tag or -asset_serial parameter , not both " + } + $apiuri= "$url/api/v1/hardware/byserial/$asset_serial" + } + $Parameters = @{ Uri = "$apiuri" Method = 'Get'