diff --git a/SnipeitPS/Public/New-Asset.ps1 b/SnipeitPS/Public/New-Asset.ps1 index db6c7f6..e6a8876 100644 --- a/SnipeitPS/Public/New-Asset.ps1 +++ b/SnipeitPS/Public/New-Asset.ps1 @@ -62,12 +62,16 @@ function New-Asset() ) $Values = @{ - "asset_tag" = $tag "name" = $Name "status_id" = $status_id "model_id" = $model_id } + if ($PSBoundParameters.ContainsKey('tag')) + { + $Values += @{"asset_tag" = $tag} + } + if ($customfields) { $Values += $customfields diff --git a/SnipeitPS/Public/Set-AssetOwner.ps1 b/SnipeitPS/Public/Set-AssetOwner.ps1 index e58febe..44d792e 100644 --- a/SnipeitPS/Public/Set-AssetOwner.ps1 +++ b/SnipeitPS/Public/Set-AssetOwner.ps1 @@ -10,7 +10,10 @@ function Set-AssetOwner() [int]$id, [parameter(mandatory = $true)] - [int]$user_id, + [int]$assigned_id, + + [ValidateSet("location","asset","user")] + [string] $checkout_to_type = "user", [parameter(mandatory = $true)] [string]$url, @@ -20,7 +23,15 @@ function Set-AssetOwner() ) $Values = @{ - "user_id" = $user_id + "id" = $assigned_id + "checkout_to_type" = $checkout_to_type + } + + switch ($checkout_to_type) + { + 'location' { $Values += @{ "assigned_location" = $assigned_id } } + 'user' { $Values += @{ "assigned_user" = $assigned_id } } + 'asset' { $Values += @{ "assigned_asset" = $assigned_id } } } $Body = $Values | ConvertTo-Json;