Do converto-json later in invoke-snipeitmethod function

This commit is contained in:
Petri Asikainen 2021-06-15 18:29:07 +03:00
parent 28a6ffd05f
commit 2850b82a16
49 changed files with 80 additions and 136 deletions

View file

@ -17,7 +17,7 @@
# Body of the request # Body of the request
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[string]$Body, [Hashtable]$Body,
[string] $Token, [string] $Token,
@ -34,6 +34,9 @@
Throw $exception Throw $exception
} }
#To support images "image" property have be handled before this
$Body = $Body | ConvertTo-Json
$_headers = @{ $_headers = @{
"Authorization" = "Bearer $($token)" "Authorization" = "Bearer $($token)"
'Content-Type' = 'application/json; charset=utf-8' 'Content-Type' = 'application/json; charset=utf-8'

View file

@ -177,7 +177,6 @@ function Get-SnipeitAsset() {
'Assets overdue for auditing' {$apiurl = "$url/api/v1/hardware/audit/overdue"} 'Assets overdue for auditing' {$apiurl = "$url/api/v1/hardware/audit/overdue"}
} }
$Parameters = @{ $Parameters = @{
Uri = $apiurl Uri = $apiurl
Method = 'Get' Method = 'Get'

View file

@ -113,12 +113,10 @@ function New-SnipeitAccessory() {
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd")
} }
$Body = $Values | ConvertTo-Json;
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/accessories" Uri = "$url/api/v1/accessories"
Method = 'POST' Method = 'POST'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -137,12 +137,10 @@ function New-SnipeitAsset()
$Values += $customfields $Values += $customfields
} }
$Body = $Values | ConvertTo-Json;
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/hardware" Uri = "$url/api/v1/hardware"
Method = 'Post' Method = 'Post'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -81,20 +81,19 @@ function New-SnipeitAssetMaintenance() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($values['start_date']) { if ($Values['start_date']) {
$values['start_date'] = $values['start_date'].ToString("yyyy-MM-dd") $Values['start_date'] = $Values['start_date'].ToString("yyyy-MM-dd")
} }
if ($values['completion_date']) { if ($Values['completion_date']) {
$values['completion_date'] = $values['completion_date'].ToString("yyyy-MM-dd") $Values['completion_date'] = $Values['completion_date'].ToString("yyyy-MM-dd")
} }
$Body = $Values | ConvertTo-Json;
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/maintenances" Uri = "$url/api/v1/maintenances"
Method = 'Post' Method = 'Post'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -48,12 +48,10 @@ function New-SnipeitAudit()
$Values += @{"asset_tag" = $tag} $Values += @{"asset_tag" = $tag}
} }
$Body = $Values | ConvertTo-Json;
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/hardware/audit" Uri = "$url/api/v1/hardware/audit"
Method = 'Post' Method = 'Post'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -68,8 +68,6 @@ function New-SnipeitCategory()
} }
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
} }
process { process {
@ -77,7 +75,7 @@ function New-SnipeitCategory()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/categories" Uri = "$url/api/v1/categories"
Method = 'POST' Method = 'POST'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -41,12 +41,10 @@ function New-SnipeitCompany()
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/companies" Uri = "$url/api/v1/companies"
Method = 'POST' Method = 'POST'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -76,16 +76,14 @@ function New-SnipeitComponent() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($values['purchase_date']) { if ($Values['purchase_date']) {
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
} }
$Body = $Values | ConvertTo-Json;
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/components" Uri = "$url/api/v1/components"
Method = 'POST' Method = 'POST'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -114,18 +114,16 @@ function New-SnipeitConsumable()
begin { begin {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($values['purchase_date']) { if ($Values['purchase_date']) {
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
} }
$Body = $Values | ConvertTo-Json;
} }
process { process {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/consumables" Uri = "$url/api/v1/consumables"
Method = 'Post' Method = 'Post'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -83,12 +83,10 @@ function New-SnipeitCustomField()
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/fields" Uri = "$url/api/v1/fields"
Method = 'post' Method = 'post'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }
} }

View file

@ -57,12 +57,10 @@ function New-SnipeitDepartment() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/departments" Uri = "$url/api/v1/departments"
Method = 'POST' Method = 'POST'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -128,24 +128,22 @@ function New-SnipeitLicense() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($values['expiration_date']) { if ($Values['expiration_date']) {
$values['expiration_date'] = $values['expiration_date'].ToString("yyyy-MM-dd") $Values['expiration_date'] = $Values['expiration_date'].ToString("yyyy-MM-dd")
} }
if ($values['purchase_date']) { if ($Values['purchase_date']) {
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
} }
if ($values['termination_date']) { if ($Values['termination_date']) {
$values['termination_date'] = $values['termination_date'].ToString("yyyy-MM-dd") $Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd")
} }
$Body = $Values | ConvertTo-Json;
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/licenses" Uri = "$url/api/v1/licenses"
Method = 'POST' Method = 'POST'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -89,12 +89,10 @@ function New-SnipeitLocation() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/locations" Uri = "$url/api/v1/locations"
Method = 'post' Method = 'post'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -42,13 +42,10 @@ function New-SnipeitManufacturer()
"name" = $Name "name" = $Name
} }
#Convert Values to JSON format
$Body = $Values | ConvertTo-Json;
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/manufacturers" Uri = "$url/api/v1/manufacturers"
Method = 'post' Method = 'post'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -73,12 +73,11 @@ function New-SnipeitModel()
if ($PSBoundParameters.ContainsKey('model_number')) { $Values.Add("model_number", $model_number) } if ($PSBoundParameters.ContainsKey('model_number')) { $Values.Add("model_number", $model_number) }
if ($PSBoundParameters.ContainsKey('eol')) { $Values.Add("eol", $eol) } if ($PSBoundParameters.ContainsKey('eol')) { $Values.Add("eol", $eol) }
$Body = $Values | ConvertTo-Json;
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/models" Uri = "$url/api/v1/models"
Method = 'post' Method = 'post'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -117,12 +117,10 @@ function New-SnipeitUser() {
$Values['password_confirmation'] = $password $Values['password_confirmation'] = $password
} }
$Body = $Values | ConvertTo-Json;
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/users" Uri = "$url/api/v1/users"
Method = 'post' Method = 'post'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -41,7 +41,7 @@ function Remove-SnipeitAccessory ()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/accessories/$accessory_id" Uri = "$url/api/v1/accessories/$accessory_id"
Method = 'Delete' Method = 'Delete'
Body = '{}' Body = @{}
Token = $apiKey Token = $apiKey
} }

View file

@ -42,7 +42,7 @@ function Remove-SnipeitAsset ()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/hardware/$asset_id" Uri = "$url/api/v1/hardware/$asset_id"
Method = 'Delete' Method = 'Delete'
Body = '{}' Body = '@{}'
Token = $apiKey Token = $apiKey
} }

View file

@ -46,7 +46,7 @@ function Remove-SnipeitAssetMaintenance {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/maintenances/$maintenance_id" Uri = "$url/api/v1/maintenances/$maintenance_id"
Method = 'Delete' Method = 'Delete'
Body = '{}' Body = '@{}'
Token = $apiKey Token = $apiKey
} }

View file

@ -41,7 +41,7 @@ function Remove-SnipeitCategory ()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/categories/$category_id" Uri = "$url/api/v1/categories/$category_id"
Method = 'Delete' Method = 'Delete'
Body = '{}' Body = '@{}'
Token = $apiKey Token = $apiKey
} }

View file

@ -41,7 +41,7 @@ function Remove-SnipeitCompany ()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/companies/$company_id" Uri = "$url/api/v1/companies/$company_id"
Method = 'Delete' Method = 'Delete'
Body = '{}' Body = '@{}'
Token = $apiKey Token = $apiKey
} }

View file

@ -41,7 +41,7 @@ function Remove-SnipeitComponent ()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/components/$component_id" Uri = "$url/api/v1/components/$component_id"
Method = 'Delete' Method = 'Delete'
Body = '{}' Body = '@{}'
Token = $apiKey Token = $apiKey
} }

View file

@ -42,7 +42,7 @@ function Remove-SnipeitConsumable ()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/consumables/$consumable_id" Uri = "$url/api/v1/consumables/$consumable_id"
Method = 'Delete' Method = 'Delete'
Body = '{}' Body = '@{}'
Token = $apiKey Token = $apiKey
} }

View file

@ -41,7 +41,7 @@ function Remove-SnipeitCustomField ()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/fields/$field_id" Uri = "$url/api/v1/fields/$field_id"
Method = 'Delete' Method = 'Delete'
Body = '{}' Body = '@{}'
Token = $apiKey Token = $apiKey
} }

View file

@ -41,7 +41,7 @@ function Remove-SnipeitDepartment ()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/departments/$department_id" Uri = "$url/api/v1/departments/$department_id"
Method = 'Delete' Method = 'Delete'
Body = '{}' Body = '@{}'
Token = $apiKey Token = $apiKey
} }

View file

@ -41,7 +41,7 @@ function Remove-SnipeitLicense ()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/licenses/$license_id" Uri = "$url/api/v1/licenses/$license_id"
Method = 'Delete' Method = 'Delete'
Body = '{}' Body = '@{}'
Token = $apiKey Token = $apiKey
} }

View file

@ -41,7 +41,7 @@ function Remove-SnipeitLocation ()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/locations/$asset_id" Uri = "$url/api/v1/locations/$asset_id"
Method = 'Delete' Method = 'Delete'
Body = '{}' Body = '@{}'
Token = $apiKey Token = $apiKey
} }

View file

@ -41,7 +41,7 @@ function Remove-SnipeitManufacturer ()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/manufacturers/$manufacturer_id_id" Uri = "$url/api/v1/manufacturers/$manufacturer_id_id"
Method = 'Delete' Method = 'Delete'
Body = '{}' Body = '@{}'
Token = $apiKey Token = $apiKey
} }

View file

@ -41,7 +41,7 @@ function Remove-SnipeitModel ()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/models/$model_id" Uri = "$url/api/v1/models/$model_id"
Method = 'Delete' Method = 'Delete'
Body = '{}' Body = '@{}'
Token = $apiKey Token = $apiKey
} }

View file

@ -41,7 +41,7 @@ function Remove-SnipeitUser ()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/users/$user_id" Uri = "$url/api/v1/users/$user_id"
Method = 'Delete' Method = 'Delete'
Body = '{}' Body = '@{}'
Token = $apiKey Token = $apiKey
} }

View file

@ -46,7 +46,7 @@ function Reset-SnipeitAccessoryOwner()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/accessories/$assigned_pivot_id/checkin" Uri = "$url/api/v1/accessories/$assigned_pivot_id/checkin"
Method = 'Post' Method = 'Post'
Body = '{}' Body = @{}
Token = $apiKey Token = $apiKey
} }

View file

@ -57,12 +57,10 @@ function Reset-SnipeitAssetOwner() {
if ($PSBoundParameters.ContainsKey('location_id')) { $Values.Add("location_id", $location_id) } if ($PSBoundParameters.ContainsKey('location_id')) { $Values.Add("location_id", $location_id) }
if ($PSBoundParameters.ContainsKey('status_id')) { $Values.Add("status_id", $status_id) } if ($PSBoundParameters.ContainsKey('status_id')) { $Values.Add("status_id", $status_id) }
$Body = $Values | ConvertTo-Json;
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/hardware/$id/checkin" Uri = "$url/api/v1/hardware/$id/checkin"
Method = 'POST' Method = 'POST'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -108,12 +108,10 @@ function Set-SnipeitAccessory() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($values['purchase_date']) { if ($Values['purchase_date']) {
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
} }
$Body = $Values | ConvertTo-Json;
Write-Verbose "Body: $Body"
} }
process { process {
@ -121,7 +119,7 @@ function Set-SnipeitAccessory() {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/accessories/$accessory_id" Uri = "$url/api/v1/accessories/$accessory_id"
Method = 'Patch' Method = 'Patch'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -46,8 +46,6 @@ function Set-SnipeitAccessoryOwner()
) )
begin{ begin{
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
} }
process { process {
@ -55,7 +53,7 @@ function Set-SnipeitAccessoryOwner()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/accessories/$accessory_id/checkout" Uri = "$url/api/v1/accessories/$accessory_id/checkout"
Method = 'POST' Method = 'POST'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -134,8 +134,8 @@ function Set-SnipeitAsset()
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($values['purchase_date']) { if ($Values['purchase_date']) {
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
} }
if ($customfields) if ($customfields)
@ -143,7 +143,6 @@ function Set-SnipeitAsset()
$Values += $customfields $Values += $customfields
} }
$Body = $Values | ConvertTo-Json;
} }
process { process {
@ -151,7 +150,7 @@ function Set-SnipeitAsset()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/hardware/$asset_id" Uri = "$url/api/v1/hardware/$asset_id"
Method = $RequestType Method = $RequestType
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -71,11 +71,11 @@ function Set-SnipeitAssetOwner()
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($Values['expected_checkin']) { if ($Values['expected_checkin']) {
$Values['expected_checkin'] = $values['expected_checkin'].ToString("yyyy-MM-dd") $Values['expected_checkin'] = $Values['expected_checkin'].ToString("yyyy-MM-dd")
} }
if ($Values['checkout_at']) { if ($Values['checkout_at']) {
$Values['checkout_at'] = $values['checkout_at'].ToString("yyyy-MM-dd") $Values['checkout_at'] = $Values['checkout_at'].ToString("yyyy-MM-dd")
} }
switch ($checkout_to_type) switch ($checkout_to_type)
@ -88,8 +88,6 @@ function Set-SnipeitAssetOwner()
#This can be removed now #This can be removed now
if($Values.ContainsKey('assigned_id')){$Values.Remove('assigned_id')} if($Values.ContainsKey('assigned_id')){$Values.Remove('assigned_id')}
$Body = $Values | ConvertTo-Json;
} }
process{ process{
@ -97,7 +95,7 @@ function Set-SnipeitAssetOwner()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/hardware/$asset_id/checkout" Uri = "$url/api/v1/hardware/$asset_id/checkout"
Method = 'POST' Method = 'POST'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -66,8 +66,6 @@ function Set-SnipeitCategory()
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
} }
process { process {
@ -75,7 +73,7 @@ function Set-SnipeitCategory()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/categories/$category_id" Uri = "$url/api/v1/categories/$category_id"
Method = 'Put' Method = 'Put'
Body = $Body Body = $values
Token = $apiKey Token = $apiKey
} }

View file

@ -45,9 +45,7 @@ function Set-SnipeitCompany()
) )
begin{ begin{
$values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $values | ConvertTo-Json;
} }
process{ process{
@ -55,7 +53,7 @@ function Set-SnipeitCompany()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/companies/$company_id" Uri = "$url/api/v1/companies/$company_id"
Method = 'Patch' Method = 'Patch'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -77,13 +77,11 @@ function Set-SnipeitComponent()
begin { begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($values['purchase_date']) { if ($Values['purchase_date']) {
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
} }
$Body = $values | ConvertTo-Json;
} }
process { process {
@ -91,7 +89,7 @@ function Set-SnipeitComponent()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/components/$component_id" Uri = "$url/api/v1/components/$component_id"
Method = 'Patch' Method = 'Patch'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -124,7 +124,6 @@ function Set-SnipeitConsumable()
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
} }
$Body = $Values | ConvertTo-Json;
} }
process { process {
@ -132,7 +131,7 @@ function Set-SnipeitConsumable()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/consumables/$consumable_id" Uri = "$url/api/v1/consumables/$consumable_id"
Method = 'Put' Method = 'Put'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -82,9 +82,6 @@ function Set-SnipeitCustomField()
} }
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
} }
process{ process{
@ -92,7 +89,7 @@ function Set-SnipeitCustomField()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/fields/$field_id" Uri = "$url/api/v1/fields/$field_id"
Method = 'Put' Method = 'Put'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -61,8 +61,6 @@ function Set-SnipeitDepartment() {
begin { begin {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
} }
process { process {
@ -70,7 +68,7 @@ function Set-SnipeitDepartment() {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/departments/$department_id" Uri = "$url/api/v1/departments/$department_id"
Method = 'Put' Method = 'Put'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -135,19 +135,18 @@ function Set-SnipeitLicense() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
if ($values['expiration_date']) { if ($Values['expiration_date']) {
$values['expiration_date'] = $values['expiration_date'].ToString("yyyy-MM-dd") $Values['expiration_date'] = $Values['expiration_date'].ToString("yyyy-MM-dd")
} }
if ($values['purchase_date']) { if ($Values['purchase_date']) {
$values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
} }
if ($values['termination_date']) { if ($Values['termination_date']) {
$values['termination_date'] = $values['termination_date'].ToString("yyyy-MM-dd") $Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd")
} }
$Body = $Values | ConvertTo-Json;
} }
process { process {
@ -155,7 +154,7 @@ function Set-SnipeitLicense() {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/licenses/$license_id" Uri = "$url/api/v1/licenses/$license_id"
Method = 'PUT' Method = 'PUT'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -61,8 +61,6 @@ function Set-SnipeitLicenseSeat()
begin{ begin{
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
} }
process{ process{
@ -70,7 +68,7 @@ function Set-SnipeitLicenseSeat()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/licenses/$license_id/seats/$seat_id" Uri = "$url/api/v1/licenses/$license_id/seats/$seat_id"
Method = 'Patch' Method = 'Patch'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -99,8 +99,6 @@ function Set-SnipeitLocation() {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
} }
process{ process{
@ -108,7 +106,7 @@ function Set-SnipeitLocation() {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/locations/$location_id" Uri = "$url/api/v1/locations/$location_id"
Method = 'PUT' Method = 'PUT'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -70,14 +70,13 @@ function Set-SnipeitModel() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
} }
process { process {
foreach ($model_id in $id) { foreach ($model_id in $id) {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/models/$model_id" Uri = "$url/api/v1/models/$model_id"
Method = 'put' Method = 'put'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -62,7 +62,6 @@ function Set-SnipeitStatus()
begin { begin {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json
} }
process { process {
@ -70,7 +69,7 @@ function Set-SnipeitStatus()
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/statuslabels/$status_id" Uri = "$url/api/v1/statuslabels/$status_id"
Method = 'Put' Method = 'Put'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }

View file

@ -111,7 +111,6 @@ function Set-SnipeitUser() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Body = $Values | ConvertTo-Json;
} }
process{ process{
@ -119,7 +118,7 @@ function Set-SnipeitUser() {
$Parameters = @{ $Parameters = @{
Uri = "$url/api/v1/users/$user_id" Uri = "$url/api/v1/users/$user_id"
Method = 'PATCH' Method = 'PATCH'
Body = $Body Body = $Values
Token = $apiKey Token = $apiKey
} }