From 2850b82a166dc02db2dec1ba7ea870b0cb194a68 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Tue, 15 Jun 2021 18:29:07 +0300 Subject: [PATCH 01/16] Do converto-json later in invoke-snipeitmethod function --- SnipeitPS/Private/Invoke-SnipeitMethod.ps1 | 5 ++++- SnipeitPS/Public/Get-SnipeitAsset.ps1 | 1 - SnipeitPS/Public/New-SnipeitAccessory.ps1 | 4 +--- SnipeitPS/Public/New-SnipeitAsset.ps1 | 4 +--- SnipeitPS/Public/New-SnipeitAssetMaintenance.ps1 | 11 +++++------ SnipeitPS/Public/New-SnipeitAudit.ps1 | 4 +--- SnipeitPS/Public/New-SnipeitCategory.ps1 | 4 +--- SnipeitPS/Public/New-SnipeitCompany.ps1 | 4 +--- SnipeitPS/Public/New-SnipeitComponent.ps1 | 8 +++----- SnipeitPS/Public/New-SnipeitConsumable.ps1 | 6 ++---- SnipeitPS/Public/New-SnipeitCustomField.ps1 | 4 +--- SnipeitPS/Public/New-SnipeitDepartment.ps1 | 4 +--- SnipeitPS/Public/New-SnipeitLicense.ps1 | 16 +++++++--------- SnipeitPS/Public/New-SnipeitLocation.ps1 | 4 +--- SnipeitPS/Public/New-SnipeitManufacturer.ps1 | 5 +---- SnipeitPS/Public/New-SnipeitModel.ps1 | 3 +-- SnipeitPS/Public/New-SnipeitUser.ps1 | 4 +--- SnipeitPS/Public/Remove-SnipeitAccessory.ps1 | 2 +- SnipeitPS/Public/Remove-SnipeitAsset.ps1 | 2 +- .../Public/Remove-SnipeitAssetMaintenance.ps1 | 2 +- SnipeitPS/Public/Remove-SnipeitCategory.ps1 | 2 +- SnipeitPS/Public/Remove-SnipeitCompany.ps1 | 2 +- SnipeitPS/Public/Remove-SnipeitComponent.ps1 | 2 +- SnipeitPS/Public/Remove-SnipeitConsumable.ps1 | 2 +- SnipeitPS/Public/Remove-SnipeitCustomField.ps1 | 2 +- SnipeitPS/Public/Remove-SnipeitDepartment.ps1 | 2 +- SnipeitPS/Public/Remove-SnipeitLicense.ps1 | 2 +- SnipeitPS/Public/Remove-SnipeitLocation.ps1 | 2 +- SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 | 2 +- SnipeitPS/Public/Remove-SnipeitModel.ps1 | 2 +- SnipeitPS/Public/Remove-SnipeitUser.ps1 | 2 +- SnipeitPS/Public/Reset-SnipeitAccessoryOwner.ps1 | 2 +- SnipeitPS/Public/Reset-SnipeitAssetOwner.ps1 | 4 +--- SnipeitPS/Public/Set-SnipeitAccessory.ps1 | 8 +++----- SnipeitPS/Public/Set-SnipeitAccessoryOwner.ps1 | 4 +--- SnipeitPS/Public/Set-SnipeitAsset.ps1 | 7 +++---- SnipeitPS/Public/Set-SnipeitAssetOwner.ps1 | 8 +++----- SnipeitPS/Public/Set-SnipeitCategory.ps1 | 4 +--- SnipeitPS/Public/Set-SnipeitCompany.ps1 | 6 ++---- SnipeitPS/Public/Set-SnipeitComponent.ps1 | 10 ++++------ SnipeitPS/Public/Set-SnipeitConsumable.ps1 | 3 +-- SnipeitPS/Public/Set-SnipeitCustomField.ps1 | 5 +---- SnipeitPS/Public/Set-SnipeitDepartment.ps1 | 4 +--- SnipeitPS/Public/Set-SnipeitLicense.ps1 | 15 +++++++-------- SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 | 4 +--- SnipeitPS/Public/Set-SnipeitLocation.ps1 | 4 +--- SnipeitPS/Public/Set-SnipeitModel.ps1 | 3 +-- SnipeitPS/Public/Set-SnipeitStatus.ps1 | 3 +-- SnipeitPS/Public/Set-SnipeitUser.ps1 | 3 +-- 49 files changed, 80 insertions(+), 136 deletions(-) diff --git a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 index 2e3779d..b6deb74 100644 --- a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 +++ b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 @@ -17,7 +17,7 @@ # Body of the request [ValidateNotNullOrEmpty()] - [string]$Body, + [Hashtable]$Body, [string] $Token, @@ -34,6 +34,9 @@ Throw $exception } + #To support images "image" property have be handled before this + $Body = $Body | ConvertTo-Json + $_headers = @{ "Authorization" = "Bearer $($token)" 'Content-Type' = 'application/json; charset=utf-8' diff --git a/SnipeitPS/Public/Get-SnipeitAsset.ps1 b/SnipeitPS/Public/Get-SnipeitAsset.ps1 index 691b260..99afa60 100644 --- a/SnipeitPS/Public/Get-SnipeitAsset.ps1 +++ b/SnipeitPS/Public/Get-SnipeitAsset.ps1 @@ -177,7 +177,6 @@ function Get-SnipeitAsset() { 'Assets overdue for auditing' {$apiurl = "$url/api/v1/hardware/audit/overdue"} } - $Parameters = @{ Uri = $apiurl Method = 'Get' diff --git a/SnipeitPS/Public/New-SnipeitAccessory.ps1 b/SnipeitPS/Public/New-SnipeitAccessory.ps1 index df4663c..83654e6 100644 --- a/SnipeitPS/Public/New-SnipeitAccessory.ps1 +++ b/SnipeitPS/Public/New-SnipeitAccessory.ps1 @@ -113,12 +113,10 @@ function New-SnipeitAccessory() { $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") } - $Body = $Values | ConvertTo-Json; - $Parameters = @{ Uri = "$url/api/v1/accessories" Method = 'POST' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/New-SnipeitAsset.ps1 b/SnipeitPS/Public/New-SnipeitAsset.ps1 index 8ca47fb..c6cf147 100644 --- a/SnipeitPS/Public/New-SnipeitAsset.ps1 +++ b/SnipeitPS/Public/New-SnipeitAsset.ps1 @@ -137,12 +137,10 @@ function New-SnipeitAsset() $Values += $customfields } - $Body = $Values | ConvertTo-Json; - $Parameters = @{ Uri = "$url/api/v1/hardware" Method = 'Post' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/New-SnipeitAssetMaintenance.ps1 b/SnipeitPS/Public/New-SnipeitAssetMaintenance.ps1 index 2115539..a62f690 100644 --- a/SnipeitPS/Public/New-SnipeitAssetMaintenance.ps1 +++ b/SnipeitPS/Public/New-SnipeitAssetMaintenance.ps1 @@ -81,20 +81,19 @@ function New-SnipeitAssetMaintenance() { $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - if ($values['start_date']) { - $values['start_date'] = $values['start_date'].ToString("yyyy-MM-dd") + if ($Values['start_date']) { + $Values['start_date'] = $Values['start_date'].ToString("yyyy-MM-dd") } - if ($values['completion_date']) { - $values['completion_date'] = $values['completion_date'].ToString("yyyy-MM-dd") + if ($Values['completion_date']) { + $Values['completion_date'] = $Values['completion_date'].ToString("yyyy-MM-dd") } - $Body = $Values | ConvertTo-Json; $Parameters = @{ Uri = "$url/api/v1/maintenances" Method = 'Post' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/New-SnipeitAudit.ps1 b/SnipeitPS/Public/New-SnipeitAudit.ps1 index b01faab..883491b 100644 --- a/SnipeitPS/Public/New-SnipeitAudit.ps1 +++ b/SnipeitPS/Public/New-SnipeitAudit.ps1 @@ -48,12 +48,10 @@ function New-SnipeitAudit() $Values += @{"asset_tag" = $tag} } - $Body = $Values | ConvertTo-Json; - $Parameters = @{ Uri = "$url/api/v1/hardware/audit" Method = 'Post' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/New-SnipeitCategory.ps1 b/SnipeitPS/Public/New-SnipeitCategory.ps1 index 62ca0e9..bb4b0ef 100644 --- a/SnipeitPS/Public/New-SnipeitCategory.ps1 +++ b/SnipeitPS/Public/New-SnipeitCategory.ps1 @@ -68,8 +68,6 @@ function New-SnipeitCategory() } $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - - $Body = $Values | ConvertTo-Json; } process { @@ -77,7 +75,7 @@ function New-SnipeitCategory() $Parameters = @{ Uri = "$url/api/v1/categories" Method = 'POST' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/New-SnipeitCompany.ps1 b/SnipeitPS/Public/New-SnipeitCompany.ps1 index 5c541a4..e85508b 100644 --- a/SnipeitPS/Public/New-SnipeitCompany.ps1 +++ b/SnipeitPS/Public/New-SnipeitCompany.ps1 @@ -41,12 +41,10 @@ function New-SnipeitCompany() $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $Body = $Values | ConvertTo-Json; - $Parameters = @{ Uri = "$url/api/v1/companies" Method = 'POST' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/New-SnipeitComponent.ps1 b/SnipeitPS/Public/New-SnipeitComponent.ps1 index 7880b76..ced3f23 100644 --- a/SnipeitPS/Public/New-SnipeitComponent.ps1 +++ b/SnipeitPS/Public/New-SnipeitComponent.ps1 @@ -76,16 +76,14 @@ function New-SnipeitComponent() { $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - if ($values['purchase_date']) { - $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") + if ($Values['purchase_date']) { + $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") } - $Body = $Values | ConvertTo-Json; - $Parameters = @{ Uri = "$url/api/v1/components" Method = 'POST' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/New-SnipeitConsumable.ps1 b/SnipeitPS/Public/New-SnipeitConsumable.ps1 index d89b691..fb7d617 100644 --- a/SnipeitPS/Public/New-SnipeitConsumable.ps1 +++ b/SnipeitPS/Public/New-SnipeitConsumable.ps1 @@ -114,18 +114,16 @@ function New-SnipeitConsumable() begin { $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") } - - $Body = $Values | ConvertTo-Json; } process { $Parameters = @{ Uri = "$url/api/v1/consumables" Method = 'Post' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/New-SnipeitCustomField.ps1 b/SnipeitPS/Public/New-SnipeitCustomField.ps1 index 454394c..2b1efbe 100644 --- a/SnipeitPS/Public/New-SnipeitCustomField.ps1 +++ b/SnipeitPS/Public/New-SnipeitCustomField.ps1 @@ -83,12 +83,10 @@ function New-SnipeitCustomField() $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $Body = $Values | ConvertTo-Json; - $Parameters = @{ Uri = "$url/api/v1/fields" Method = 'post' - Body = $Body + Body = $Values Token = $apiKey } } diff --git a/SnipeitPS/Public/New-SnipeitDepartment.ps1 b/SnipeitPS/Public/New-SnipeitDepartment.ps1 index 73dbedb..d7334ba 100644 --- a/SnipeitPS/Public/New-SnipeitDepartment.ps1 +++ b/SnipeitPS/Public/New-SnipeitDepartment.ps1 @@ -57,12 +57,10 @@ function New-SnipeitDepartment() { $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $Body = $Values | ConvertTo-Json; - $Parameters = @{ Uri = "$url/api/v1/departments" Method = 'POST' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/New-SnipeitLicense.ps1 b/SnipeitPS/Public/New-SnipeitLicense.ps1 index baac560..11a49fb 100644 --- a/SnipeitPS/Public/New-SnipeitLicense.ps1 +++ b/SnipeitPS/Public/New-SnipeitLicense.ps1 @@ -128,24 +128,22 @@ function New-SnipeitLicense() { $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - if ($values['expiration_date']) { - $values['expiration_date'] = $values['expiration_date'].ToString("yyyy-MM-dd") + if ($Values['expiration_date']) { + $Values['expiration_date'] = $Values['expiration_date'].ToString("yyyy-MM-dd") } - if ($values['purchase_date']) { - $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") + if ($Values['purchase_date']) { + $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") } - if ($values['termination_date']) { - $values['termination_date'] = $values['termination_date'].ToString("yyyy-MM-dd") + if ($Values['termination_date']) { + $Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd") } - $Body = $Values | ConvertTo-Json; - $Parameters = @{ Uri = "$url/api/v1/licenses" Method = 'POST' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/New-SnipeitLocation.ps1 b/SnipeitPS/Public/New-SnipeitLocation.ps1 index e2751f6..17c351b 100644 --- a/SnipeitPS/Public/New-SnipeitLocation.ps1 +++ b/SnipeitPS/Public/New-SnipeitLocation.ps1 @@ -89,12 +89,10 @@ function New-SnipeitLocation() { $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $Body = $Values | ConvertTo-Json; - $Parameters = @{ Uri = "$url/api/v1/locations" Method = 'post' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/New-SnipeitManufacturer.ps1 b/SnipeitPS/Public/New-SnipeitManufacturer.ps1 index f7abf31..d97ab4c 100644 --- a/SnipeitPS/Public/New-SnipeitManufacturer.ps1 +++ b/SnipeitPS/Public/New-SnipeitManufacturer.ps1 @@ -42,13 +42,10 @@ function New-SnipeitManufacturer() "name" = $Name } - #Convert Values to JSON format - $Body = $Values | ConvertTo-Json; - $Parameters = @{ Uri = "$url/api/v1/manufacturers" Method = 'post' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/New-SnipeitModel.ps1 b/SnipeitPS/Public/New-SnipeitModel.ps1 index 5e36b8a..d0ff9a6 100644 --- a/SnipeitPS/Public/New-SnipeitModel.ps1 +++ b/SnipeitPS/Public/New-SnipeitModel.ps1 @@ -73,12 +73,11 @@ function New-SnipeitModel() if ($PSBoundParameters.ContainsKey('model_number')) { $Values.Add("model_number", $model_number) } if ($PSBoundParameters.ContainsKey('eol')) { $Values.Add("eol", $eol) } - $Body = $Values | ConvertTo-Json; $Parameters = @{ Uri = "$url/api/v1/models" Method = 'post' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/New-SnipeitUser.ps1 b/SnipeitPS/Public/New-SnipeitUser.ps1 index 33306fc..0077eb8 100644 --- a/SnipeitPS/Public/New-SnipeitUser.ps1 +++ b/SnipeitPS/Public/New-SnipeitUser.ps1 @@ -117,12 +117,10 @@ function New-SnipeitUser() { $Values['password_confirmation'] = $password } - $Body = $Values | ConvertTo-Json; - $Parameters = @{ Uri = "$url/api/v1/users" Method = 'post' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitAccessory.ps1 b/SnipeitPS/Public/Remove-SnipeitAccessory.ps1 index 387ab01..d8303fe 100644 --- a/SnipeitPS/Public/Remove-SnipeitAccessory.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitAccessory.ps1 @@ -41,7 +41,7 @@ function Remove-SnipeitAccessory () $Parameters = @{ Uri = "$url/api/v1/accessories/$accessory_id" Method = 'Delete' - Body = '{}' + Body = @{} Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitAsset.ps1 b/SnipeitPS/Public/Remove-SnipeitAsset.ps1 index 47811e7..fb2edbd 100644 --- a/SnipeitPS/Public/Remove-SnipeitAsset.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitAsset.ps1 @@ -42,7 +42,7 @@ function Remove-SnipeitAsset () $Parameters = @{ Uri = "$url/api/v1/hardware/$asset_id" Method = 'Delete' - Body = '{}' + Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitAssetMaintenance.ps1 b/SnipeitPS/Public/Remove-SnipeitAssetMaintenance.ps1 index 10cc017..4bae969 100644 --- a/SnipeitPS/Public/Remove-SnipeitAssetMaintenance.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitAssetMaintenance.ps1 @@ -46,7 +46,7 @@ function Remove-SnipeitAssetMaintenance { $Parameters = @{ Uri = "$url/api/v1/maintenances/$maintenance_id" Method = 'Delete' - Body = '{}' + Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitCategory.ps1 b/SnipeitPS/Public/Remove-SnipeitCategory.ps1 index 873858b..f1c2912 100644 --- a/SnipeitPS/Public/Remove-SnipeitCategory.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitCategory.ps1 @@ -41,7 +41,7 @@ function Remove-SnipeitCategory () $Parameters = @{ Uri = "$url/api/v1/categories/$category_id" Method = 'Delete' - Body = '{}' + Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitCompany.ps1 b/SnipeitPS/Public/Remove-SnipeitCompany.ps1 index d9b4758..85966f0 100644 --- a/SnipeitPS/Public/Remove-SnipeitCompany.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitCompany.ps1 @@ -41,7 +41,7 @@ function Remove-SnipeitCompany () $Parameters = @{ Uri = "$url/api/v1/companies/$company_id" Method = 'Delete' - Body = '{}' + Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitComponent.ps1 b/SnipeitPS/Public/Remove-SnipeitComponent.ps1 index 2dfd012..6644ca3 100644 --- a/SnipeitPS/Public/Remove-SnipeitComponent.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitComponent.ps1 @@ -41,7 +41,7 @@ function Remove-SnipeitComponent () $Parameters = @{ Uri = "$url/api/v1/components/$component_id" Method = 'Delete' - Body = '{}' + Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitConsumable.ps1 b/SnipeitPS/Public/Remove-SnipeitConsumable.ps1 index 0bda660..d1dc453 100644 --- a/SnipeitPS/Public/Remove-SnipeitConsumable.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitConsumable.ps1 @@ -42,7 +42,7 @@ function Remove-SnipeitConsumable () $Parameters = @{ Uri = "$url/api/v1/consumables/$consumable_id" Method = 'Delete' - Body = '{}' + Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitCustomField.ps1 b/SnipeitPS/Public/Remove-SnipeitCustomField.ps1 index 291eac4..ead644c 100644 --- a/SnipeitPS/Public/Remove-SnipeitCustomField.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitCustomField.ps1 @@ -41,7 +41,7 @@ function Remove-SnipeitCustomField () $Parameters = @{ Uri = "$url/api/v1/fields/$field_id" Method = 'Delete' - Body = '{}' + Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitDepartment.ps1 b/SnipeitPS/Public/Remove-SnipeitDepartment.ps1 index 8bf9daa..f2e545b 100644 --- a/SnipeitPS/Public/Remove-SnipeitDepartment.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitDepartment.ps1 @@ -41,7 +41,7 @@ function Remove-SnipeitDepartment () $Parameters = @{ Uri = "$url/api/v1/departments/$department_id" Method = 'Delete' - Body = '{}' + Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitLicense.ps1 b/SnipeitPS/Public/Remove-SnipeitLicense.ps1 index 094435c..f096cc6 100644 --- a/SnipeitPS/Public/Remove-SnipeitLicense.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitLicense.ps1 @@ -41,7 +41,7 @@ function Remove-SnipeitLicense () $Parameters = @{ Uri = "$url/api/v1/licenses/$license_id" Method = 'Delete' - Body = '{}' + Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitLocation.ps1 b/SnipeitPS/Public/Remove-SnipeitLocation.ps1 index d0bfa94..07a8e6f 100644 --- a/SnipeitPS/Public/Remove-SnipeitLocation.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitLocation.ps1 @@ -41,7 +41,7 @@ function Remove-SnipeitLocation () $Parameters = @{ Uri = "$url/api/v1/locations/$asset_id" Method = 'Delete' - Body = '{}' + Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 b/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 index 40a87ca..92afad1 100644 --- a/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 @@ -41,7 +41,7 @@ function Remove-SnipeitManufacturer () $Parameters = @{ Uri = "$url/api/v1/manufacturers/$manufacturer_id_id" Method = 'Delete' - Body = '{}' + Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitModel.ps1 b/SnipeitPS/Public/Remove-SnipeitModel.ps1 index 788710f..b8c5565 100644 --- a/SnipeitPS/Public/Remove-SnipeitModel.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitModel.ps1 @@ -41,7 +41,7 @@ function Remove-SnipeitModel () $Parameters = @{ Uri = "$url/api/v1/models/$model_id" Method = 'Delete' - Body = '{}' + Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitUser.ps1 b/SnipeitPS/Public/Remove-SnipeitUser.ps1 index ca254bf..18d2361 100644 --- a/SnipeitPS/Public/Remove-SnipeitUser.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitUser.ps1 @@ -41,7 +41,7 @@ function Remove-SnipeitUser () $Parameters = @{ Uri = "$url/api/v1/users/$user_id" Method = 'Delete' - Body = '{}' + Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Reset-SnipeitAccessoryOwner.ps1 b/SnipeitPS/Public/Reset-SnipeitAccessoryOwner.ps1 index a85ca2c..060bb90 100644 --- a/SnipeitPS/Public/Reset-SnipeitAccessoryOwner.ps1 +++ b/SnipeitPS/Public/Reset-SnipeitAccessoryOwner.ps1 @@ -46,7 +46,7 @@ function Reset-SnipeitAccessoryOwner() $Parameters = @{ Uri = "$url/api/v1/accessories/$assigned_pivot_id/checkin" Method = 'Post' - Body = '{}' + Body = @{} Token = $apiKey } diff --git a/SnipeitPS/Public/Reset-SnipeitAssetOwner.ps1 b/SnipeitPS/Public/Reset-SnipeitAssetOwner.ps1 index 9340d42..6a55915 100644 --- a/SnipeitPS/Public/Reset-SnipeitAssetOwner.ps1 +++ b/SnipeitPS/Public/Reset-SnipeitAssetOwner.ps1 @@ -57,12 +57,10 @@ function Reset-SnipeitAssetOwner() { if ($PSBoundParameters.ContainsKey('location_id')) { $Values.Add("location_id", $location_id) } if ($PSBoundParameters.ContainsKey('status_id')) { $Values.Add("status_id", $status_id) } - $Body = $Values | ConvertTo-Json; - $Parameters = @{ Uri = "$url/api/v1/hardware/$id/checkin" Method = 'POST' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitAccessory.ps1 b/SnipeitPS/Public/Set-SnipeitAccessory.ps1 index 54110e1..9c14436 100644 --- a/SnipeitPS/Public/Set-SnipeitAccessory.ps1 +++ b/SnipeitPS/Public/Set-SnipeitAccessory.ps1 @@ -108,12 +108,10 @@ function Set-SnipeitAccessory() { $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - if ($values['purchase_date']) { - $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") + if ($Values['purchase_date']) { + $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") } - $Body = $Values | ConvertTo-Json; - Write-Verbose "Body: $Body" } process { @@ -121,7 +119,7 @@ function Set-SnipeitAccessory() { $Parameters = @{ Uri = "$url/api/v1/accessories/$accessory_id" Method = 'Patch' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitAccessoryOwner.ps1 b/SnipeitPS/Public/Set-SnipeitAccessoryOwner.ps1 index 513c74c..4a6a319 100644 --- a/SnipeitPS/Public/Set-SnipeitAccessoryOwner.ps1 +++ b/SnipeitPS/Public/Set-SnipeitAccessoryOwner.ps1 @@ -46,8 +46,6 @@ function Set-SnipeitAccessoryOwner() ) begin{ $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - - $Body = $Values | ConvertTo-Json; } process { @@ -55,7 +53,7 @@ function Set-SnipeitAccessoryOwner() $Parameters = @{ Uri = "$url/api/v1/accessories/$accessory_id/checkout" Method = 'POST' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitAsset.ps1 b/SnipeitPS/Public/Set-SnipeitAsset.ps1 index 277cc7f..f64e253 100644 --- a/SnipeitPS/Public/Set-SnipeitAsset.ps1 +++ b/SnipeitPS/Public/Set-SnipeitAsset.ps1 @@ -134,8 +134,8 @@ function Set-SnipeitAsset() $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - if ($values['purchase_date']) { - $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") + if ($Values['purchase_date']) { + $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") } if ($customfields) @@ -143,7 +143,6 @@ function Set-SnipeitAsset() $Values += $customfields } - $Body = $Values | ConvertTo-Json; } process { @@ -151,7 +150,7 @@ function Set-SnipeitAsset() $Parameters = @{ Uri = "$url/api/v1/hardware/$asset_id" Method = $RequestType - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitAssetOwner.ps1 b/SnipeitPS/Public/Set-SnipeitAssetOwner.ps1 index 5d859f5..0157c48 100644 --- a/SnipeitPS/Public/Set-SnipeitAssetOwner.ps1 +++ b/SnipeitPS/Public/Set-SnipeitAssetOwner.ps1 @@ -71,11 +71,11 @@ function Set-SnipeitAssetOwner() $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters 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']) { - $Values['checkout_at'] = $values['checkout_at'].ToString("yyyy-MM-dd") + $Values['checkout_at'] = $Values['checkout_at'].ToString("yyyy-MM-dd") } switch ($checkout_to_type) @@ -88,8 +88,6 @@ function Set-SnipeitAssetOwner() #This can be removed now if($Values.ContainsKey('assigned_id')){$Values.Remove('assigned_id')} - $Body = $Values | ConvertTo-Json; - } process{ @@ -97,7 +95,7 @@ function Set-SnipeitAssetOwner() $Parameters = @{ Uri = "$url/api/v1/hardware/$asset_id/checkout" Method = 'POST' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitCategory.ps1 b/SnipeitPS/Public/Set-SnipeitCategory.ps1 index a1603e9..de8b85a 100644 --- a/SnipeitPS/Public/Set-SnipeitCategory.ps1 +++ b/SnipeitPS/Public/Set-SnipeitCategory.ps1 @@ -66,8 +66,6 @@ function Set-SnipeitCategory() Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - - $Body = $Values | ConvertTo-Json; } process { @@ -75,7 +73,7 @@ function Set-SnipeitCategory() $Parameters = @{ Uri = "$url/api/v1/categories/$category_id" Method = 'Put' - Body = $Body + Body = $values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitCompany.ps1 b/SnipeitPS/Public/Set-SnipeitCompany.ps1 index 4dcbb16..5c9cd49 100644 --- a/SnipeitPS/Public/Set-SnipeitCompany.ps1 +++ b/SnipeitPS/Public/Set-SnipeitCompany.ps1 @@ -45,9 +45,7 @@ function Set-SnipeitCompany() ) begin{ - $values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - - $Body = $values | ConvertTo-Json; + $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters } process{ @@ -55,7 +53,7 @@ function Set-SnipeitCompany() $Parameters = @{ Uri = "$url/api/v1/companies/$company_id" Method = 'Patch' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitComponent.ps1 b/SnipeitPS/Public/Set-SnipeitComponent.ps1 index 97115d9..681d380 100644 --- a/SnipeitPS/Public/Set-SnipeitComponent.ps1 +++ b/SnipeitPS/Public/Set-SnipeitComponent.ps1 @@ -77,13 +77,11 @@ function Set-SnipeitComponent() begin { 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']) { - $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") + if ($Values['purchase_date']) { + $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") } - - $Body = $values | ConvertTo-Json; } process { @@ -91,7 +89,7 @@ function Set-SnipeitComponent() $Parameters = @{ Uri = "$url/api/v1/components/$component_id" Method = 'Patch' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitConsumable.ps1 b/SnipeitPS/Public/Set-SnipeitConsumable.ps1 index 7ea74dc..5dd8960 100644 --- a/SnipeitPS/Public/Set-SnipeitConsumable.ps1 +++ b/SnipeitPS/Public/Set-SnipeitConsumable.ps1 @@ -124,7 +124,6 @@ function Set-SnipeitConsumable() $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") } - $Body = $Values | ConvertTo-Json; } process { @@ -132,7 +131,7 @@ function Set-SnipeitConsumable() $Parameters = @{ Uri = "$url/api/v1/consumables/$consumable_id" Method = 'Put' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitCustomField.ps1 b/SnipeitPS/Public/Set-SnipeitCustomField.ps1 index de84f8d..d2dc817 100644 --- a/SnipeitPS/Public/Set-SnipeitCustomField.ps1 +++ b/SnipeitPS/Public/Set-SnipeitCustomField.ps1 @@ -82,9 +82,6 @@ function Set-SnipeitCustomField() } $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - - $Body = $Values | ConvertTo-Json; - } process{ @@ -92,7 +89,7 @@ function Set-SnipeitCustomField() $Parameters = @{ Uri = "$url/api/v1/fields/$field_id" Method = 'Put' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitDepartment.ps1 b/SnipeitPS/Public/Set-SnipeitDepartment.ps1 index 8a66063..063ec2d 100644 --- a/SnipeitPS/Public/Set-SnipeitDepartment.ps1 +++ b/SnipeitPS/Public/Set-SnipeitDepartment.ps1 @@ -61,8 +61,6 @@ function Set-SnipeitDepartment() { begin { $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - - $Body = $Values | ConvertTo-Json; } process { @@ -70,7 +68,7 @@ function Set-SnipeitDepartment() { $Parameters = @{ Uri = "$url/api/v1/departments/$department_id" Method = 'Put' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitLicense.ps1 b/SnipeitPS/Public/Set-SnipeitLicense.ps1 index 9f1d1c7..ea99b9d 100644 --- a/SnipeitPS/Public/Set-SnipeitLicense.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLicense.ps1 @@ -135,19 +135,18 @@ function Set-SnipeitLicense() { $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - if ($values['expiration_date']) { - $values['expiration_date'] = $values['expiration_date'].ToString("yyyy-MM-dd") + if ($Values['expiration_date']) { + $Values['expiration_date'] = $Values['expiration_date'].ToString("yyyy-MM-dd") } - if ($values['purchase_date']) { - $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") + if ($Values['purchase_date']) { + $Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd") } - if ($values['termination_date']) { - $values['termination_date'] = $values['termination_date'].ToString("yyyy-MM-dd") + if ($Values['termination_date']) { + $Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd") } - $Body = $Values | ConvertTo-Json; } process { @@ -155,7 +154,7 @@ function Set-SnipeitLicense() { $Parameters = @{ Uri = "$url/api/v1/licenses/$license_id" Method = 'PUT' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 b/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 index 78f9525..6e191c5 100644 --- a/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 @@ -61,8 +61,6 @@ function Set-SnipeitLicenseSeat() begin{ $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - - $Body = $Values | ConvertTo-Json; } process{ @@ -70,7 +68,7 @@ function Set-SnipeitLicenseSeat() $Parameters = @{ Uri = "$url/api/v1/licenses/$license_id/seats/$seat_id" Method = 'Patch' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitLocation.ps1 b/SnipeitPS/Public/Set-SnipeitLocation.ps1 index 4a24d86..05a0c1b 100644 --- a/SnipeitPS/Public/Set-SnipeitLocation.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLocation.ps1 @@ -99,8 +99,6 @@ function Set-SnipeitLocation() { Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - - $Body = $Values | ConvertTo-Json; } process{ @@ -108,7 +106,7 @@ function Set-SnipeitLocation() { $Parameters = @{ Uri = "$url/api/v1/locations/$location_id" Method = 'PUT' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitModel.ps1 b/SnipeitPS/Public/Set-SnipeitModel.ps1 index 894802e..312d8f1 100644 --- a/SnipeitPS/Public/Set-SnipeitModel.ps1 +++ b/SnipeitPS/Public/Set-SnipeitModel.ps1 @@ -70,14 +70,13 @@ function Set-SnipeitModel() { $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $Body = $Values | ConvertTo-Json; } process { foreach ($model_id in $id) { $Parameters = @{ Uri = "$url/api/v1/models/$model_id" Method = 'put' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitStatus.ps1 b/SnipeitPS/Public/Set-SnipeitStatus.ps1 index 54ee8d8..fe9867f 100644 --- a/SnipeitPS/Public/Set-SnipeitStatus.ps1 +++ b/SnipeitPS/Public/Set-SnipeitStatus.ps1 @@ -62,7 +62,6 @@ function Set-SnipeitStatus() begin { $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $Body = $Values | ConvertTo-Json } process { @@ -70,7 +69,7 @@ function Set-SnipeitStatus() $Parameters = @{ Uri = "$url/api/v1/statuslabels/$status_id" Method = 'Put' - Body = $Body + Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitUser.ps1 b/SnipeitPS/Public/Set-SnipeitUser.ps1 index 124acf7..256abeb 100644 --- a/SnipeitPS/Public/Set-SnipeitUser.ps1 +++ b/SnipeitPS/Public/Set-SnipeitUser.ps1 @@ -111,7 +111,6 @@ function Set-SnipeitUser() { $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters - $Body = $Values | ConvertTo-Json; } process{ @@ -119,7 +118,7 @@ function Set-SnipeitUser() { $Parameters = @{ Uri = "$url/api/v1/users/$user_id" Method = 'PATCH' - Body = $Body + Body = $Values Token = $apiKey } From d9be192b3e16406592e6a17af840f576361d2ff2 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Wed, 16 Jun 2021 00:52:32 +0300 Subject: [PATCH 02/16] Convert body only when it exist --- SnipeitPS/Private/Invoke-SnipeitMethod.ps1 | 4 ++-- SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 index b6deb74..4fedbef 100644 --- a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 +++ b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 @@ -35,7 +35,7 @@ } #To support images "image" property have be handled before this - $Body = $Body | ConvertTo-Json + if($Body) { $body = $Body | ConvertTo-Json } $_headers = @{ "Authorization" = "Bearer $($token)" @@ -66,7 +66,7 @@ $script:PSDefaultParameterValues = $global:PSDefaultParameterValues - Write-Debug $Body + Write-Debug "$($Body | ConvertTo-Json)" # Invoke the API try { diff --git a/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 b/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 index 6e191c5..9a42a09 100644 --- a/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 @@ -46,9 +46,11 @@ function Set-SnipeitLicenseSeat() [int]$seat_id, [Alias('assigned_id')] - [int]$assigned_to, - [int]$asset_id, + [Nullable[System.Int32]]$assigned_to, + + + [Nullable[System.Int32]]$asset_id, [string]$note, From 193f3f7f110677586f1c5e8fda084dbd224c15a6 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Mon, 21 Jun 2021 10:13:43 +0300 Subject: [PATCH 03/16] use invoke-webrequest, plan support for images --- SnipeitPS/Private/Invoke-SnipeitMethod.ps1 | 42 ++++++++++++++-------- SnipeitPS/Public/Set-SnipeitAccessory.ps1 | 14 ++------ docs/Set-SnipeitAccessory.md | 21 +++++++++-- 3 files changed, 48 insertions(+), 29 deletions(-) diff --git a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 index 4fedbef..5f66bdf 100644 --- a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 +++ b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 @@ -35,7 +35,6 @@ } #To support images "image" property have be handled before this - if($Body) { $body = $Body | ConvertTo-Json } $_headers = @{ "Authorization" = "Bearer $($token)" @@ -60,9 +59,24 @@ Headers = $_headers UseBasicParsing = $true ErrorAction = 'SilentlyContinue' + Proxy = 'http://localhost:8080' } - if ($Body) {$splatParameters["Body"] = [System.Text.Encoding]::UTF8.GetBytes($Body)} + #Place holder for intended image manipulation + # if and when snipe it API gets support for images + if($null -ne $body -and $Body.Keys -contains 'image' ){ + if($PSVersionTable.PSVersion -ge 7){ + $Body['image'] = get-item $body['image'] + $splatParameters["Form"] = $Body + } else { + write-warning "Setting images is supported only with powershell version 7 or greater" + $Body.Remove('image') + } + } + + if ($Body -and $splatParameters.Keys -notcontains 'Form') { + $splatParameters["Body"] = $Body | Convertto-Json + } $script:PSDefaultParameterValues = $global:PSDefaultParameterValues @@ -72,7 +86,7 @@ try { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Invoking method $Method to URI $URi" Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoke-WebRequest with: $($splatParameters | Out-String)" - $webResponse = Invoke-WebRequest @splatParameters + $webResponse = Invoke-RestMethod @splatParameters } catch { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Failed to get an answer from the server" @@ -84,27 +98,27 @@ if ($webResponse) { Write-Verbose "[$($MyInvocation.MyCommand.Name)] Status code: $($webResponse.StatusCode)" - if ($webResponse.Content) { - Write-Verbose $webResponse.Content + if ($webResponse) { + Write-Verbose $webResponse # API returned a Content: lets work wit it try{ - $response = ConvertFrom-Json -InputObject $webResponse.Content - if ($response.status -eq "error") { + if ($webResponse.status -eq "error") { Write-Verbose "[$($MyInvocation.MyCommand.Name)] An error response was received from; resolving" # This could be handled nicely in an function such as: # ResolveError $response -WriteError - Write-Error $($response.messages | Out-String) + Write-Error $($webResponse.messages | Out-String) } else { - $result = $response - if (($response) -and ($response | Get-Member -Name payload)) - { - $result = $response.payload + + if ($webResponse.payload){ + $result = $webResponse.payload } - elseif (($response) -and ($response | Get-Member -Name rows)) { - $result = $response.rows + elseif ($webResponse.rows) { + $result = $webResponse.rows + } else { + $result = $webResponse } $result diff --git a/SnipeitPS/Public/Set-SnipeitAccessory.ps1 b/SnipeitPS/Public/Set-SnipeitAccessory.ps1 index 2a10a2c..4f9ce41 100644 --- a/SnipeitPS/Public/Set-SnipeitAccessory.ps1 +++ b/SnipeitPS/Public/Set-SnipeitAccessory.ps1 @@ -38,24 +38,12 @@ Cost of item being purchased. .PARAMETER purchase_date Date accessory was purchased -.PARAMETER order_number -Order number for this accessory. - -.PARAMETER purchase_cost -Cost of item being purchased. - -.PARAMETER purchase_date -Date accessory was purchased - .PARAMETER supplier_id ID number of the supplier for this accessory .PARAMETER location_id ID number of the location the accessory is assigned to -.PARAMETER min_qty -Min quantity of the accessory before alert is triggered - .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command @@ -100,6 +88,8 @@ function Set-SnipeitAccessory() { [Nullable[System.Int32]]$supplier_id, + [Nullable[System.Int32]]$location_id, + [parameter(mandatory = $true)] [string]$url, diff --git a/docs/Set-SnipeitAccessory.md b/docs/Set-SnipeitAccessory.md index 9adeae2..433351a 100644 --- a/docs/Set-SnipeitAccessory.md +++ b/docs/Set-SnipeitAccessory.md @@ -16,7 +16,7 @@ Updates accessory on Snipe-It system Set-SnipeitAccessory [-id] [[-name] ] [[-qty] ] [[-category_id] ] [[-company_id] ] [[-manufacturer_id] ] [[-model_number] ] [[-order_number] ] [[-purchase_cost] ] [[-purchase_date] ] [[-min_amt] ] [[-supplier_id] ] - [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-location_id] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -40,7 +40,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 14 +Position: 15 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -91,6 +91,21 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -location_id +ID number of the location the accessory is assigned to + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 13 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -manufacturer_id ID number of the manufacturer for this accessory. @@ -235,7 +250,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 13 +Position: 14 Default value: None Accept pipeline input: False Accept wildcard characters: False From 508e484b17905ef3c7cb4e6a39c973ad49ce6911 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Mon, 21 Jun 2021 10:42:00 +0300 Subject: [PATCH 04/16] Be quiet when deleting --- SnipeitPS/Private/Invoke-SnipeitMethod.ps1 | 17 +++++++++++++++-- SnipeitPS/Public/Remove-SnipeitAccessory.ps1 | 1 - SnipeitPS/Public/Remove-SnipeitAsset.ps1 | 1 - .../Public/Remove-SnipeitAssetMaintenance.ps1 | 1 - SnipeitPS/Public/Remove-SnipeitCategory.ps1 | 1 - SnipeitPS/Public/Remove-SnipeitCompany.ps1 | 1 - SnipeitPS/Public/Remove-SnipeitComponent.ps1 | 1 - SnipeitPS/Public/Remove-SnipeitConsumable.ps1 | 1 - SnipeitPS/Public/Remove-SnipeitCustomField.ps1 | 1 - SnipeitPS/Public/Remove-SnipeitDepartment.ps1 | 1 - SnipeitPS/Public/Remove-SnipeitLicense.ps1 | 1 - SnipeitPS/Public/Remove-SnipeitLocation.ps1 | 1 - SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 | 1 - SnipeitPS/Public/Remove-SnipeitModel.ps1 | 1 - SnipeitPS/Public/Remove-SnipeitUser.ps1 | 1 - 15 files changed, 15 insertions(+), 16 deletions(-) diff --git a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 index 5f66bdf..58d72ce 100644 --- a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 +++ b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 @@ -111,17 +111,30 @@ Write-Error $($webResponse.messages | Out-String) } else { - + #update operations return payload if ($webResponse.payload){ $result = $webResponse.payload } + #Search operations return rows elseif ($webResponse.rows) { $result = $webResponse.rows - } else { + } + #Remove operations returns status and message + elseif ($webResponse.status -eq 'success'){ + $result = $webResponse.payload + } + #get operations with id returns just one object + else { $result = $webResponse } + Write-Verbose "Status: $($webResponse.status)" + Write-Verbose "Messages: $($webResponse.messages)" + $result + + + } } catch { diff --git a/SnipeitPS/Public/Remove-SnipeitAccessory.ps1 b/SnipeitPS/Public/Remove-SnipeitAccessory.ps1 index d8303fe..4189b17 100644 --- a/SnipeitPS/Public/Remove-SnipeitAccessory.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitAccessory.ps1 @@ -41,7 +41,6 @@ function Remove-SnipeitAccessory () $Parameters = @{ Uri = "$url/api/v1/accessories/$accessory_id" Method = 'Delete' - Body = @{} Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitAsset.ps1 b/SnipeitPS/Public/Remove-SnipeitAsset.ps1 index fb2edbd..68d9dbb 100644 --- a/SnipeitPS/Public/Remove-SnipeitAsset.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitAsset.ps1 @@ -42,7 +42,6 @@ function Remove-SnipeitAsset () $Parameters = @{ Uri = "$url/api/v1/hardware/$asset_id" Method = 'Delete' - Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitAssetMaintenance.ps1 b/SnipeitPS/Public/Remove-SnipeitAssetMaintenance.ps1 index 4bae969..a1f7b65 100644 --- a/SnipeitPS/Public/Remove-SnipeitAssetMaintenance.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitAssetMaintenance.ps1 @@ -46,7 +46,6 @@ function Remove-SnipeitAssetMaintenance { $Parameters = @{ Uri = "$url/api/v1/maintenances/$maintenance_id" Method = 'Delete' - Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitCategory.ps1 b/SnipeitPS/Public/Remove-SnipeitCategory.ps1 index f1c2912..0f86693 100644 --- a/SnipeitPS/Public/Remove-SnipeitCategory.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitCategory.ps1 @@ -41,7 +41,6 @@ function Remove-SnipeitCategory () $Parameters = @{ Uri = "$url/api/v1/categories/$category_id" Method = 'Delete' - Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitCompany.ps1 b/SnipeitPS/Public/Remove-SnipeitCompany.ps1 index 85966f0..9ff94dc 100644 --- a/SnipeitPS/Public/Remove-SnipeitCompany.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitCompany.ps1 @@ -41,7 +41,6 @@ function Remove-SnipeitCompany () $Parameters = @{ Uri = "$url/api/v1/companies/$company_id" Method = 'Delete' - Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitComponent.ps1 b/SnipeitPS/Public/Remove-SnipeitComponent.ps1 index 6644ca3..450dbed 100644 --- a/SnipeitPS/Public/Remove-SnipeitComponent.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitComponent.ps1 @@ -41,7 +41,6 @@ function Remove-SnipeitComponent () $Parameters = @{ Uri = "$url/api/v1/components/$component_id" Method = 'Delete' - Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitConsumable.ps1 b/SnipeitPS/Public/Remove-SnipeitConsumable.ps1 index d1dc453..3e18b3d 100644 --- a/SnipeitPS/Public/Remove-SnipeitConsumable.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitConsumable.ps1 @@ -42,7 +42,6 @@ function Remove-SnipeitConsumable () $Parameters = @{ Uri = "$url/api/v1/consumables/$consumable_id" Method = 'Delete' - Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitCustomField.ps1 b/SnipeitPS/Public/Remove-SnipeitCustomField.ps1 index ead644c..e258ca2 100644 --- a/SnipeitPS/Public/Remove-SnipeitCustomField.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitCustomField.ps1 @@ -41,7 +41,6 @@ function Remove-SnipeitCustomField () $Parameters = @{ Uri = "$url/api/v1/fields/$field_id" Method = 'Delete' - Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitDepartment.ps1 b/SnipeitPS/Public/Remove-SnipeitDepartment.ps1 index f2e545b..d6e95c7 100644 --- a/SnipeitPS/Public/Remove-SnipeitDepartment.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitDepartment.ps1 @@ -41,7 +41,6 @@ function Remove-SnipeitDepartment () $Parameters = @{ Uri = "$url/api/v1/departments/$department_id" Method = 'Delete' - Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitLicense.ps1 b/SnipeitPS/Public/Remove-SnipeitLicense.ps1 index f096cc6..ba0dee4 100644 --- a/SnipeitPS/Public/Remove-SnipeitLicense.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitLicense.ps1 @@ -41,7 +41,6 @@ function Remove-SnipeitLicense () $Parameters = @{ Uri = "$url/api/v1/licenses/$license_id" Method = 'Delete' - Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitLocation.ps1 b/SnipeitPS/Public/Remove-SnipeitLocation.ps1 index 07a8e6f..15c4567 100644 --- a/SnipeitPS/Public/Remove-SnipeitLocation.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitLocation.ps1 @@ -41,7 +41,6 @@ function Remove-SnipeitLocation () $Parameters = @{ Uri = "$url/api/v1/locations/$asset_id" Method = 'Delete' - Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 b/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 index 92afad1..b9c109b 100644 --- a/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 @@ -41,7 +41,6 @@ function Remove-SnipeitManufacturer () $Parameters = @{ Uri = "$url/api/v1/manufacturers/$manufacturer_id_id" Method = 'Delete' - Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitModel.ps1 b/SnipeitPS/Public/Remove-SnipeitModel.ps1 index b8c5565..65509bd 100644 --- a/SnipeitPS/Public/Remove-SnipeitModel.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitModel.ps1 @@ -41,7 +41,6 @@ function Remove-SnipeitModel () $Parameters = @{ Uri = "$url/api/v1/models/$model_id" Method = 'Delete' - Body = '@{}' Token = $apiKey } diff --git a/SnipeitPS/Public/Remove-SnipeitUser.ps1 b/SnipeitPS/Public/Remove-SnipeitUser.ps1 index 18d2361..6afd60b 100644 --- a/SnipeitPS/Public/Remove-SnipeitUser.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitUser.ps1 @@ -41,7 +41,6 @@ function Remove-SnipeitUser () $Parameters = @{ Uri = "$url/api/v1/users/$user_id" Method = 'Delete' - Body = '@{}' Token = $apiKey } From d4b6fc595b791b6ba5aa137ce4a2bc25cd0d41ec Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Wed, 23 Jun 2021 18:48:13 +0300 Subject: [PATCH 05/16] removed debug proxy --- SnipeitPS/Private/Invoke-SnipeitMethod.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 index 58d72ce..464d92b 100644 --- a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 +++ b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 @@ -59,7 +59,6 @@ Headers = $_headers UseBasicParsing = $true ErrorAction = 'SilentlyContinue' - Proxy = 'http://localhost:8080' } #Place holder for intended image manipulation From e8077d5c21c63e651229c6f196f7d5c16616d02b Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Thu, 8 Jul 2021 23:56:58 +0300 Subject: [PATCH 06/16] switch parameter to booleans --- SnipeitPS/Private/Get-ParameterValue.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/SnipeitPS/Private/Get-ParameterValue.ps1 b/SnipeitPS/Private/Get-ParameterValue.ps1 index afb4039..e2d702b 100644 --- a/SnipeitPS/Private/Get-ParameterValue.ps1 +++ b/SnipeitPS/Private/Get-ParameterValue.ps1 @@ -57,5 +57,13 @@ function Get-ParameterValue { } finally {} } + + #Convert switch parameters to booleans so it converts nicely to json + foreach ( $key in @($ParameterValues.Keys)) { + if ($true -eq $ParameterValues[$key].IsPresent){ + $ParameterValues[$key]=$true; + } + } + return $ParameterValues } From 3ac0bbceb2b2f4c4d7699edb0a917f0f18769193 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Thu, 8 Jul 2021 23:59:31 +0300 Subject: [PATCH 07/16] set and remove images --- SnipeitPS/Private/Invoke-SnipeitMethod.ps1 | 8 ++-- SnipeitPS/Public/New-SnipeitAccessory.ps1 | 11 +++++ SnipeitPS/Public/New-SnipeitAsset.ps1 | 11 +++++ SnipeitPS/Public/New-SnipeitCategory.ps1 | 13 +++++- SnipeitPS/Public/New-SnipeitCompany.ps1 | 11 +++++ SnipeitPS/Public/New-SnipeitComponent.ps1 | 11 +++++ SnipeitPS/Public/New-SnipeitConsumable.ps1 | 11 +++++ SnipeitPS/Public/New-SnipeitDepartment.ps1 | 11 +++++ SnipeitPS/Public/New-SnipeitLocation.ps1 | 11 +++++ SnipeitPS/Public/New-SnipeitManufacturer.ps1 | 11 +++++ SnipeitPS/Public/New-SnipeitModel.ps1 | 11 +++++ SnipeitPS/Public/New-SnipeitUser.ps1 | 10 +++++ SnipeitPS/Public/Set-SnipeitAccessory.ps1 | 11 +++++ SnipeitPS/Public/Set-SnipeitAsset.ps1 | 13 +++++- SnipeitPS/Public/Set-SnipeitCategory.ps1 | 23 ++++++++--- SnipeitPS/Public/Set-SnipeitCompany.ps1 | 11 +++++ SnipeitPS/Public/Set-SnipeitComponent.ps1 | 11 +++++ SnipeitPS/Public/Set-SnipeitConsumable.ps1 | 11 +++++ SnipeitPS/Public/Set-SnipeitDepartment.ps1 | 11 +++++ SnipeitPS/Public/Set-SnipeitLocation.ps1 | 11 +++++ SnipeitPS/Public/Set-SnipeitModel.ps1 | 11 +++++ SnipeitPS/Public/Set-SnipeitUser.ps1 | 11 +++++ docs/New-SnipeitAccessory.md | 37 +++++++++++++++-- docs/New-SnipeitAsset.md | 40 ++++++++++++++++--- docs/New-SnipeitCategory.md | 38 ++++++++++++++++-- docs/New-SnipeitCompany.md | 38 ++++++++++++++++-- docs/New-SnipeitComponent.md | 37 +++++++++++++++-- docs/New-SnipeitConsumable.md | 38 ++++++++++++++++-- docs/New-SnipeitDepartment.md | 37 +++++++++++++++-- docs/New-SnipeitLocation.md | 38 ++++++++++++++++-- docs/New-SnipeitManufacturer.md | 38 ++++++++++++++++-- docs/New-SnipeitModel.md | 38 ++++++++++++++++-- docs/New-SnipeitUser.md | 38 ++++++++++++++++-- docs/Set-SnipeitAccessory.md | 37 +++++++++++++++-- docs/Set-SnipeitAsset.md | 42 +++++++++++++++++--- docs/Set-SnipeitCategory.md | 39 ++++++++++++++++-- docs/Set-SnipeitCompany.md | 38 ++++++++++++++++-- docs/Set-SnipeitComponent.md | 37 +++++++++++++++-- docs/Set-SnipeitConsumable.md | 38 ++++++++++++++++-- docs/Set-SnipeitDepartment.md | 38 ++++++++++++++++-- docs/Set-SnipeitLocation.md | 38 ++++++++++++++++-- docs/Set-SnipeitModel.md | 38 ++++++++++++++++-- docs/Set-SnipeitUser.md | 38 ++++++++++++++++-- 43 files changed, 961 insertions(+), 93 deletions(-) diff --git a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 index 464d92b..8e9ac84 100644 --- a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 +++ b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 @@ -64,12 +64,14 @@ #Place holder for intended image manipulation # if and when snipe it API gets support for images if($null -ne $body -and $Body.Keys -contains 'image' ){ - if($PSVersionTable.PSVersion -ge 7){ + if($PSVersionTable.PSVersion -ge '7.0'){ $Body['image'] = get-item $body['image'] $splatParameters["Form"] = $Body } else { - write-warning "Setting images is supported only with powershell version 7 or greater" - $Body.Remove('image') + # use base64 encoded images for powershell version < 7 + Add-Type -AssemblyName "System.Web" + $mimetype = [System.Web.MimeMapping]::GetMimeMapping($body['image']) + $Body['image'] = 'data:@'+$mimetype+';base64,'+[Convert]::ToBase64String([IO.File]::ReadAllBytes($Body['image'])) } } diff --git a/SnipeitPS/Public/New-SnipeitAccessory.ps1 b/SnipeitPS/Public/New-SnipeitAccessory.ps1 index a7df00d..0957c77 100644 --- a/SnipeitPS/Public/New-SnipeitAccessory.ps1 +++ b/SnipeitPS/Public/New-SnipeitAccessory.ps1 @@ -53,6 +53,12 @@ ID number of the location the accessory is assigned to .PARAMETER min_amt Min quantity of the accessory before alert is triggered +.PARAMETER image +Image file name and path for item + +.PARAMETER image_delete +Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -103,6 +109,11 @@ function New-SnipeitAccessory() { [ValidateRange(1, [int]::MaxValue)] [int]$location_id, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitAsset.ps1 b/SnipeitPS/Public/New-SnipeitAsset.ps1 index c6cf147..c0e7c4f 100644 --- a/SnipeitPS/Public/New-SnipeitAsset.ps1 +++ b/SnipeitPS/Public/New-SnipeitAsset.ps1 @@ -42,6 +42,12 @@ Optional Purchase cost of the Asset .PARAMETER rtd_location_id Optional Default location id for the asset +.PARAMETER image +Image file name and path for item + +.PARAMETER image_delete +Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -114,6 +120,11 @@ function New-SnipeitAsset() [parameter(mandatory = $false)] [int]$rtd_location_id, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitCategory.ps1 b/SnipeitPS/Public/New-SnipeitCategory.ps1 index bb4b0ef..2c61c49 100644 --- a/SnipeitPS/Public/New-SnipeitCategory.ps1 +++ b/SnipeitPS/Public/New-SnipeitCategory.ps1 @@ -20,6 +20,12 @@ If switch is present, require users to confirm acceptance of assets in this cate .PARAMETER checkin_email If switch is present, send email to user on checkin/checkout +.PARAMETER image +Image file name and path for item + +.PARAMETER image_delete +Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -47,12 +53,17 @@ function New-SnipeitCategory() [string]$eula_text, - [switch]$use_default_eula, [switch]$require_acceptance, [switch]$checkin_email, + + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitCompany.ps1 b/SnipeitPS/Public/New-SnipeitCompany.ps1 index e85508b..4bc41bf 100644 --- a/SnipeitPS/Public/New-SnipeitCompany.ps1 +++ b/SnipeitPS/Public/New-SnipeitCompany.ps1 @@ -8,6 +8,12 @@ Creates new company on Snipe-It system .PARAMETER name Comapany name +.PARAMETER image +Image file name and path for item + +.PARAMETER image_delete +Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -30,6 +36,11 @@ function New-SnipeitCompany() [parameter(mandatory = $true)] [string]$name, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitComponent.ps1 b/SnipeitPS/Public/New-SnipeitComponent.ps1 index ced3f23..7d75a19 100644 --- a/SnipeitPS/Public/New-SnipeitComponent.ps1 +++ b/SnipeitPS/Public/New-SnipeitComponent.ps1 @@ -26,6 +26,12 @@ Date accessory was purchased .PARAMETER purchase_cost Cost of item being purchased. +.PARAMETER image +Image file name and path for item + +.PARAMETER image_delete +Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -65,6 +71,11 @@ function New-SnipeitComponent() { [float]$purchase_cost, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitConsumable.ps1 b/SnipeitPS/Public/New-SnipeitConsumable.ps1 index fb7d617..6ac6c5c 100644 --- a/SnipeitPS/Public/New-SnipeitConsumable.ps1 +++ b/SnipeitPS/Public/New-SnipeitConsumable.ps1 @@ -44,6 +44,12 @@ Model number of the consumable in months .PARAMETER item_no Item number for the consumable +.PARAMETER image +Image file name and path for item + +.PARAMETER image_delete +Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -104,6 +110,11 @@ function New-SnipeitConsumable() [parameter(mandatory = $false)] [string]$item_no, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitDepartment.ps1 b/SnipeitPS/Public/New-SnipeitDepartment.ps1 index d7334ba..5e5d337 100644 --- a/SnipeitPS/Public/New-SnipeitDepartment.ps1 +++ b/SnipeitPS/Public/New-SnipeitDepartment.ps1 @@ -17,6 +17,12 @@ .PARAMETER manager_id ID number of manager + .PARAMETER image + Image file name and path for item + + .PARAMETER image_delete + Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -46,6 +52,11 @@ function New-SnipeitDepartment() { [string]$notes, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitLocation.ps1 b/SnipeitPS/Public/New-SnipeitLocation.ps1 index 17c351b..32e858d 100644 --- a/SnipeitPS/Public/New-SnipeitLocation.ps1 +++ b/SnipeitPS/Public/New-SnipeitLocation.ps1 @@ -38,6 +38,12 @@ .PARAMETER manager_id The manager ID of the location + .PARAMETER image + Image file name and path for item + + .PARAMETER image_delete + Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -78,6 +84,11 @@ function New-SnipeitLocation() { [string]$ldap_ou, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitManufacturer.ps1 b/SnipeitPS/Public/New-SnipeitManufacturer.ps1 index d97ab4c..1811aa9 100644 --- a/SnipeitPS/Public/New-SnipeitManufacturer.ps1 +++ b/SnipeitPS/Public/New-SnipeitManufacturer.ps1 @@ -8,6 +8,12 @@ .PARAMETER Name Name of the Manufacturer + .PARAMETER image + Image file name and path for item + + .PARAMETER image_delete + Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -29,6 +35,11 @@ function New-SnipeitManufacturer() [parameter(mandatory = $true)] [string]$Name, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitModel.ps1 b/SnipeitPS/Public/New-SnipeitModel.ps1 index d0ff9a6..1480800 100644 --- a/SnipeitPS/Public/New-SnipeitModel.ps1 +++ b/SnipeitPS/Public/New-SnipeitModel.ps1 @@ -20,6 +20,12 @@ .PARAMETER fieldset_id Fieldset ID that the asset uses (Custom fields) + .PARAMETER image + Image file name and path for item + + .PARAMETER image_delete + Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -54,6 +60,11 @@ function New-SnipeitModel() [parameter(mandatory = $true)] [int]$fieldset_id, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitUser.ps1 b/SnipeitPS/Public/New-SnipeitUser.ps1 index 108fc3c..138a377 100644 --- a/SnipeitPS/Public/New-SnipeitUser.ps1 +++ b/SnipeitPS/Public/New-SnipeitUser.ps1 @@ -50,6 +50,12 @@ .PARAMETER ldap_import Mark user as import from ldap + .PARAMETER image + Image file name and path for item + + .PARAMETER image_delete + Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -104,6 +110,10 @@ function New-SnipeitUser() { [bool]$ldap_import = $false, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/Set-SnipeitAccessory.ps1 b/SnipeitPS/Public/Set-SnipeitAccessory.ps1 index 4f9ce41..66032dc 100644 --- a/SnipeitPS/Public/Set-SnipeitAccessory.ps1 +++ b/SnipeitPS/Public/Set-SnipeitAccessory.ps1 @@ -44,6 +44,12 @@ ID number of the supplier for this accessory .PARAMETER location_id ID number of the location the accessory is assigned to +.PARAMETER image +Image file name and path for item + +.PARAMETER image_delete +Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command @@ -90,6 +96,11 @@ function Set-SnipeitAccessory() { [Nullable[System.Int32]]$location_id, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/Set-SnipeitAsset.ps1 b/SnipeitPS/Public/Set-SnipeitAsset.ps1 index 856a92a..b375fda 100644 --- a/SnipeitPS/Public/Set-SnipeitAsset.ps1 +++ b/SnipeitPS/Public/Set-SnipeitAsset.ps1 @@ -53,8 +53,14 @@ .PARAMETER notes Notes about asset + .PARAMETER image + Image file name and path for item + + .PARAMETER image_delete + Remove current image + .PARAMETER RequestType - Http request type to send Snipe IT system. Defaults to Put youc use Patch if needed + Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command @@ -122,6 +128,11 @@ function Set-SnipeitAsset() [ValidateSet("Put","Patch")] [string]$RequestType = "Patch", + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/Set-SnipeitCategory.ps1 b/SnipeitPS/Public/Set-SnipeitCategory.ps1 index de8b85a..33edafd 100644 --- a/SnipeitPS/Public/Set-SnipeitCategory.ps1 +++ b/SnipeitPS/Public/Set-SnipeitCategory.ps1 @@ -8,12 +8,6 @@ Name of new category to be created .PARAMETER type Type of new category to be created (asset, accessory, consumable, component, license) -.PARAMETER url -URL of Snipeit system, can be set using Set-SnipeitInfo command - -.PARAMETER apiKey -User's API Key for Snipeit, can be set using Set-SnipeitInfo command - .PARAMETER use_default_eula If switch is present, use the primary default EULA @@ -26,6 +20,18 @@ If switch is present, require users to confirm acceptance of assets in this cate .PARAMETER checkin_email Should the user be emailed the EULA and/or an acceptance confirmation email when this item is checked in? +.PARAMETER image +Image file name and path for item + +.PARAMETER image_delete +Remove current image + +.PARAMETER url +URL of Snipeit system, can be set using Set-SnipeitInfo command + +.PARAMETER apiKey +User's API Key for Snipeit, can be set using Set-SnipeitInfo command + .EXAMPLE Set-SnipeitCategory -id 4 -name "Laptops" #> @@ -54,6 +60,11 @@ function Set-SnipeitCategory() [bool]$checkin_email, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/Set-SnipeitCompany.ps1 b/SnipeitPS/Public/Set-SnipeitCompany.ps1 index 5c9cd49..ee12e3c 100644 --- a/SnipeitPS/Public/Set-SnipeitCompany.ps1 +++ b/SnipeitPS/Public/Set-SnipeitCompany.ps1 @@ -11,6 +11,12 @@ ID number of company .PARAMETER name Company name +.PARAMETER image +Image file name and path for item + +.PARAMETER image_delete +Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -37,6 +43,11 @@ function Set-SnipeitCompany() [parameter(mandatory = $true)] [string]$name, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/Set-SnipeitComponent.ps1 b/SnipeitPS/Public/Set-SnipeitComponent.ps1 index d85a286..e622a33 100644 --- a/SnipeitPS/Public/Set-SnipeitComponent.ps1 +++ b/SnipeitPS/Public/Set-SnipeitComponent.ps1 @@ -32,6 +32,12 @@ Date accessory was purchased .PARAMETER purchase_cost Cost of item being purchased. +.PARAMETER image +Image file name and path for item + +.PARAMETER image_delete +Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -73,6 +79,11 @@ function Set-SnipeitComponent() [float]$purchase_cost, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/Set-SnipeitConsumable.ps1 b/SnipeitPS/Public/Set-SnipeitConsumable.ps1 index b98805d..319ebf6 100644 --- a/SnipeitPS/Public/Set-SnipeitConsumable.ps1 +++ b/SnipeitPS/Public/Set-SnipeitConsumable.ps1 @@ -47,6 +47,12 @@ Model number of the consumable in months .PARAMETER item_no Item number for the consumable +.PARAMETER image +Image file name and path for item + +.PARAMETER image_delete +Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -112,6 +118,11 @@ function Set-SnipeitConsumable() [parameter(mandatory = $false)] [string]$item_no, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/Set-SnipeitDepartment.ps1 b/SnipeitPS/Public/Set-SnipeitDepartment.ps1 index dd4830b..81bd7e0 100644 --- a/SnipeitPS/Public/Set-SnipeitDepartment.ps1 +++ b/SnipeitPS/Public/Set-SnipeitDepartment.ps1 @@ -20,6 +20,12 @@ .PARAMETER manager_id ID number of manager + .PARAMETER image + Image file name and path for item + + .PARAMETER image_delete + Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -51,6 +57,11 @@ function Set-SnipeitDepartment() { [string]$notes, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/Set-SnipeitLocation.ps1 b/SnipeitPS/Public/Set-SnipeitLocation.ps1 index a5ff9f2..8021ab9 100644 --- a/SnipeitPS/Public/Set-SnipeitLocation.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLocation.ps1 @@ -44,6 +44,12 @@ .PARAMETER parent_id Parent location as id + .PARAMETER image + Image file name and path for item + + .PARAMETER image_delete + Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -88,6 +94,11 @@ function Set-SnipeitLocation() { [Nullable[System.Int32]]$parent_id, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/Set-SnipeitModel.ps1 b/SnipeitPS/Public/Set-SnipeitModel.ps1 index d46258b..4d99df6 100644 --- a/SnipeitPS/Public/Set-SnipeitModel.ps1 +++ b/SnipeitPS/Public/Set-SnipeitModel.ps1 @@ -23,6 +23,12 @@ .PARAMETER fieldset_id Fieldset ID that the asset uses (Custom fields) + .PARAMETER image + Image file name and path for item + + .PARAMETER image_delete + Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -57,6 +63,11 @@ function Set-SnipeitModel() { [Alias("fieldset_id")] [Nullable[System.Int32]]$custom_fieldset_id, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/Set-SnipeitUser.ps1 b/SnipeitPS/Public/Set-SnipeitUser.ps1 index 341258e..17e9662 100644 --- a/SnipeitPS/Public/Set-SnipeitUser.ps1 +++ b/SnipeitPS/Public/Set-SnipeitUser.ps1 @@ -53,6 +53,12 @@ .PARAMETER ldap_import Mark user as import from ldap + .PARAMETER image + Image file name and path for item + + .PARAMETER image_delete + Remove current image + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -107,6 +113,11 @@ function Set-SnipeitUser() { [string]$notes, + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + [parameter(mandatory = $true)] [string]$url, diff --git a/docs/New-SnipeitAccessory.md b/docs/New-SnipeitAccessory.md index de15744..b2fae75 100644 --- a/docs/New-SnipeitAccessory.md +++ b/docs/New-SnipeitAccessory.md @@ -16,7 +16,8 @@ Creates new accessory on Snipe-It system New-SnipeitAccessory [-name] [-qty] [-category_id] [[-company_id] ] [[-manufacturer_id] ] [[-order_number] ] [[-model_number] ] [[-purchase_cost] ] [[-purchase_date] ] [[-min_amt] ] [[-supplier_id] ] [[-location_id] ] - [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-image] ] [-image_delete] [-url] [-apiKey] [-WhatIf] [-Confirm] + [] ``` ## DESCRIPTION @@ -40,7 +41,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 14 +Position: 15 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -76,6 +77,36 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 13 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -location_id ID number of the location the accessory is assigned to @@ -235,7 +266,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 13 +Position: 14 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/New-SnipeitAsset.md b/docs/New-SnipeitAsset.md index 34bef7c..f1eedc1 100644 --- a/docs/New-SnipeitAsset.md +++ b/docs/New-SnipeitAsset.md @@ -16,8 +16,8 @@ Add a new Asset to Snipe-it asset system New-SnipeitAsset [-status_id] [-model_id] [[-name] ] [[-asset_tag] ] [[-serial] ] [[-company_id] ] [[-order_number] ] [[-notes] ] [[-warranty_months] ] [[-purchase_cost] ] [[-purchase_date] ] - [[-supplier_id] ] [[-rtd_location_id] ] [-url] [-apiKey] - [[-customfields] ] [-WhatIf] [-Confirm] [] + [[-supplier_id] ] [[-rtd_location_id] ] [[-image] ] [-image_delete] [-url] + [-apiKey] [[-customfields] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -54,7 +54,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 15 +Position: 16 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -100,12 +100,42 @@ Parameter Sets: (All) Aliases: CustomValues Required: False -Position: 16 +Position: 17 Default value: None Accept pipeline input: False Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 14 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -model_id Required Model ID of the asset, this can be got using Get-Model @@ -265,7 +295,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 14 +Position: 15 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/New-SnipeitCategory.md b/docs/New-SnipeitCategory.md index beaa7dc..e25ed93 100644 --- a/docs/New-SnipeitCategory.md +++ b/docs/New-SnipeitCategory.md @@ -14,8 +14,8 @@ Create a new Snipe-IT Category ``` New-SnipeitCategory [-name] [-category_type] [[-eula_text] ] [-use_default_eula] - [-require_acceptance] [-checkin_email] [-url] [-apiKey] [-WhatIf] [-Confirm] - [] + [-require_acceptance] [-checkin_email] [[-image] ] [-image_delete] [-url] [-apiKey] + [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -39,7 +39,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 5 +Position: 6 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -90,6 +90,36 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -name Name of new category to be created @@ -129,7 +159,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 4 +Position: 5 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/New-SnipeitCompany.md b/docs/New-SnipeitCompany.md index 3d7a389..667ca2f 100644 --- a/docs/New-SnipeitCompany.md +++ b/docs/New-SnipeitCompany.md @@ -13,8 +13,8 @@ Creates a new Company ## SYNTAX ``` -New-SnipeitCompany [-name] [-url] [-apiKey] [-WhatIf] [-Confirm] - [] +New-SnipeitCompany [-name] [[-image] ] [-image_delete] [-url] [-apiKey] + [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -38,12 +38,42 @@ Parameter Sets: (All) Aliases: Required: True -Position: 3 +Position: 4 Default value: None Accept pipeline input: False Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -name Comapany name @@ -68,7 +98,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 2 +Position: 3 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/New-SnipeitComponent.md b/docs/New-SnipeitComponent.md index 19a69e5..b00755b 100644 --- a/docs/New-SnipeitComponent.md +++ b/docs/New-SnipeitComponent.md @@ -15,7 +15,8 @@ Create a new component ``` New-SnipeitComponent [-name] [-category_id] [-qty] [[-company_id] ] [[-location_id] ] [[-order_number] ] [[-purchase_date] ] [[-purchase_cost] ] - [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-image] ] [-image_delete] [-url] [-apiKey] [-WhatIf] [-Confirm] + [] ``` ## DESCRIPTION @@ -39,7 +40,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 10 +Position: 11 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -75,6 +76,36 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 9 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -location_id ID number of the location the accessory is assigned to @@ -174,7 +205,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 9 +Position: 10 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/New-SnipeitConsumable.md b/docs/New-SnipeitConsumable.md index c030a82..9fba0eb 100644 --- a/docs/New-SnipeitConsumable.md +++ b/docs/New-SnipeitConsumable.md @@ -16,8 +16,8 @@ Add a new Consumable to Snipe-it asset system New-SnipeitConsumable [-name] [-qty] [-category_id] [[-min_amt] ] [[-company_id] ] [[-order_number] ] [[-manufacturer_id] ] [[-location_id] ] [[-requestable] ] [[-purchase_date] ] [[-purchase_cost] ] - [[-model_number] ] [[-item_no] ] [-url] [-apiKey] [-WhatIf] [-Confirm] - [] + [[-model_number] ] [[-item_no] ] [[-image] ] [-image_delete] [-url] + [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -42,7 +42,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 15 +Position: 16 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -78,6 +78,36 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 14 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -item_no Item number for the consumable @@ -252,7 +282,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 14 +Position: 15 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/New-SnipeitDepartment.md b/docs/New-SnipeitDepartment.md index a5a01b5..c60f4a5 100644 --- a/docs/New-SnipeitDepartment.md +++ b/docs/New-SnipeitDepartment.md @@ -14,7 +14,8 @@ Creates a department ``` New-SnipeitDepartment [-name] [[-company_id] ] [[-location_id] ] [[-manager_id] ] - [[-notes] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-notes] ] [[-image] ] [-image_delete] [-url] [-apiKey] [-WhatIf] + [-Confirm] [] ``` ## DESCRIPTION @@ -38,7 +39,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 7 +Position: 8 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -59,6 +60,36 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 6 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -location_id ID number of location @@ -128,7 +159,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 6 +Position: 7 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/New-SnipeitLocation.md b/docs/New-SnipeitLocation.md index 6b12649..93c927d 100644 --- a/docs/New-SnipeitLocation.md +++ b/docs/New-SnipeitLocation.md @@ -15,8 +15,8 @@ Add a new Location to Snipe-it asset system ``` New-SnipeitLocation [-name] [[-address] ] [[-address2] ] [[-city] ] [[-state] ] [[-country] ] [[-zip] ] [[-currency] ] [[-parent_id] ] - [[-manager_id] ] [[-ldap_ou] ] [-url] [-apiKey] [-WhatIf] [-Confirm] - [] + [[-manager_id] ] [[-ldap_ou] ] [[-image] ] [-image_delete] [-url] + [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -70,7 +70,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 13 +Position: 14 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -121,6 +121,36 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 12 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -ldap_ou The LDAP OU of the location @@ -205,7 +235,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 12 +Position: 13 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/New-SnipeitManufacturer.md b/docs/New-SnipeitManufacturer.md index 434bb49..2ed5dcb 100644 --- a/docs/New-SnipeitManufacturer.md +++ b/docs/New-SnipeitManufacturer.md @@ -13,8 +13,8 @@ Add a new Manufacturer to Snipe-it asset system ## SYNTAX ``` -New-SnipeitManufacturer [-Name] [-url] [-apiKey] [-WhatIf] [-Confirm] - [] +New-SnipeitManufacturer [-Name] [[-image] ] [-image_delete] [-url] [-apiKey] + [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -38,12 +38,42 @@ Parameter Sets: (All) Aliases: Required: True -Position: 3 +Position: 4 Default value: None Accept pipeline input: False Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Name Name of the Manufacturer @@ -68,7 +98,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 2 +Position: 3 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/New-SnipeitModel.md b/docs/New-SnipeitModel.md index ea055b5..d46eefb 100644 --- a/docs/New-SnipeitModel.md +++ b/docs/New-SnipeitModel.md @@ -14,8 +14,8 @@ Add a new Model to Snipe-it asset system ``` New-SnipeitModel [-name] [[-model_number] ] [-category_id] [-manufacturer_id] - [[-eol] ] [-fieldset_id] [-url] [-apiKey] [-WhatIf] [-Confirm] - [] + [[-eol] ] [-fieldset_id] [[-image] ] [-image_delete] [-url] [-apiKey] + [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -39,7 +39,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 8 +Position: 9 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -90,6 +90,36 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 7 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -manufacturer_id Manufacturer ID that the asset belongs to this can be got using Get-Manufacturer @@ -144,7 +174,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 7 +Position: 8 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/New-SnipeitUser.md b/docs/New-SnipeitUser.md index 99a4cc0..43c9334 100644 --- a/docs/New-SnipeitUser.md +++ b/docs/New-SnipeitUser.md @@ -16,8 +16,8 @@ Creates a new user New-SnipeitUser [-first_name] [-last_name] [-username] [[-password] ] [[-activated] ] [[-notes] ] [[-jobtitle] ] [[-email] ] [[-phone] ] [[-company_id] ] [[-location_id] ] [[-department_id] ] [[-manager_id] ] - [[-employee_num] ] [[-ldap_import] ] [-url] [-apiKey] [-WhatIf] [-Confirm] - [] + [[-employee_num] ] [[-ldap_import] ] [[-image] ] [-image_delete] [-url] + [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -57,7 +57,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 17 +Position: 18 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -138,6 +138,36 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 16 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -jobtitle Users job tittle @@ -267,7 +297,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 16 +Position: 17 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitAccessory.md b/docs/Set-SnipeitAccessory.md index 433351a..cc4b3eb 100644 --- a/docs/Set-SnipeitAccessory.md +++ b/docs/Set-SnipeitAccessory.md @@ -16,7 +16,8 @@ Updates accessory on Snipe-It system Set-SnipeitAccessory [-id] [[-name] ] [[-qty] ] [[-category_id] ] [[-company_id] ] [[-manufacturer_id] ] [[-model_number] ] [[-order_number] ] [[-purchase_cost] ] [[-purchase_date] ] [[-min_amt] ] [[-supplier_id] ] - [[-location_id] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-location_id] ] [[-image] ] [-image_delete] [-url] [-apiKey] [-WhatIf] + [-Confirm] [] ``` ## DESCRIPTION @@ -40,7 +41,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 15 +Position: 16 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -91,6 +92,36 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 14 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -location_id ID number of the location the accessory is assigned to @@ -250,7 +281,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 14 +Position: 15 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitAsset.md b/docs/Set-SnipeitAsset.md index 900e5da..84476cf 100644 --- a/docs/Set-SnipeitAsset.md +++ b/docs/Set-SnipeitAsset.md @@ -17,8 +17,8 @@ Set-SnipeitAsset [-id] [[-name] ] [[-status_id] ] [[-mo [[-last_checkout] ] [[-assigned_to] ] [[-company_id] ] [[-serial] ] [[-order_number] ] [[-warranty_months] ] [[-purchase_cost] ] [[-purchase_date] ] [[-requestable] ] [[-archived] ] [[-rtd_location_id] ] - [[-notes] ] [[-RequestType] ] [-url] [-apiKey] [[-customfields] ] - [-WhatIf] [-Confirm] [] + [[-notes] ] [[-RequestType] ] [[-image] ] [-image_delete] [-url] + [-apiKey] [[-customfields] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -52,7 +52,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 19 +Position: 20 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -113,7 +113,7 @@ Parameter Sets: (All) Aliases: CustomValues Required: False -Position: 20 +Position: 21 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -134,6 +134,36 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 18 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -last_checkout Date the asset was last checked out @@ -256,7 +286,7 @@ Accept wildcard characters: False ### -RequestType Http request type to send Snipe IT system. -Defaults to Put youc use Patch if needed +Defaults to Patch you could use Put if needed. ```yaml Type: String @@ -324,7 +354,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 18 +Position: 19 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitCategory.md b/docs/Set-SnipeitCategory.md index a380ae5..e78566c 100644 --- a/docs/Set-SnipeitCategory.md +++ b/docs/Set-SnipeitCategory.md @@ -14,8 +14,9 @@ Create a new Snipe-IT Category ``` Set-SnipeitCategory [-id] [[-name] ] [[-category_type] ] [[-eula_text] ] - [[-use_default_eula] ] [[-require_acceptance] ] [[-checkin_email] ] [-url] - [-apiKey] [-WhatIf] [-Confirm] [] + [[-use_default_eula] ] [[-require_acceptance] ] [[-checkin_email] ] + [[-image] ] [-image_delete] [-url] [-apiKey] [-WhatIf] [-Confirm] + [] ``` ## DESCRIPTION @@ -39,7 +40,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 9 +Position: 10 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -105,6 +106,36 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 8 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -name Name of new category to be created @@ -144,7 +175,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 8 +Position: 9 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitCompany.md b/docs/Set-SnipeitCompany.md index 53ee457..d23077a 100644 --- a/docs/Set-SnipeitCompany.md +++ b/docs/Set-SnipeitCompany.md @@ -13,8 +13,8 @@ Updates company name ## SYNTAX ``` -Set-SnipeitCompany [-id] [-name] [-url] [-apiKey] [-WhatIf] [-Confirm] - [] +Set-SnipeitCompany [-id] [-name] [[-image] ] [-image_delete] [-url] + [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -38,7 +38,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 4 +Position: 5 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -59,6 +59,36 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -name Company name @@ -83,7 +113,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 3 +Position: 4 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitComponent.md b/docs/Set-SnipeitComponent.md index 69b6a50..b2cc8ad 100644 --- a/docs/Set-SnipeitComponent.md +++ b/docs/Set-SnipeitComponent.md @@ -15,7 +15,8 @@ Updates component ``` Set-SnipeitComponent [-id] [-qty] [[-min_amt] ] [[-name] ] [[-company_id] ] [[-location_id] ] [[-order_number] ] [[-purchase_date] ] - [[-purchase_cost] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-purchase_cost] ] [[-image] ] [-image_delete] [-url] [-apiKey] [-WhatIf] + [-Confirm] [] ``` ## DESCRIPTION @@ -39,7 +40,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 11 +Position: 12 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -75,6 +76,36 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 10 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -location_id ID number of the location the accessory is assigned to @@ -189,7 +220,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 10 +Position: 11 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitConsumable.md b/docs/Set-SnipeitConsumable.md index 2379254..ecdde9c 100644 --- a/docs/Set-SnipeitConsumable.md +++ b/docs/Set-SnipeitConsumable.md @@ -16,8 +16,8 @@ Add a new Consumable to Snipe-it asset system Set-SnipeitConsumable [-id] [[-name] ] [[-qty] ] [[-category_id] ] [[-min_amt] ] [[-company_id] ] [[-order_number] ] [[-manufacturer_id] ] [[-location_id] ] [[-requestable] ] [[-purchase_date] ] [[-purchase_cost] ] - [[-model_number] ] [[-item_no] ] [-url] [-apiKey] [-WhatIf] [-Confirm] - [] + [[-model_number] ] [[-item_no] ] [[-image] ] [-image_delete] [-url] + [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -42,7 +42,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 16 +Position: 17 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -93,6 +93,36 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 15 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -item_no Item number for the consumable @@ -267,7 +297,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 15 +Position: 16 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitDepartment.md b/docs/Set-SnipeitDepartment.md index c701fc9..ca6e6a1 100644 --- a/docs/Set-SnipeitDepartment.md +++ b/docs/Set-SnipeitDepartment.md @@ -14,8 +14,8 @@ Updates a department ``` Set-SnipeitDepartment [-id] [[-name] ] [[-company_id] ] [[-location_id] ] - [[-manager_id] ] [[-notes] ] [-url] [-apiKey] [-WhatIf] [-Confirm] - [] + [[-manager_id] ] [[-notes] ] [[-image] ] [-image_delete] [-url] + [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -39,7 +39,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 8 +Position: 9 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -75,6 +75,36 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 7 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -location_id ID number of location @@ -144,7 +174,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 7 +Position: 8 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitLocation.md b/docs/Set-SnipeitLocation.md index f1fa607..4a8b9f1 100644 --- a/docs/Set-SnipeitLocation.md +++ b/docs/Set-SnipeitLocation.md @@ -15,8 +15,8 @@ Updates Location in Snipe-it asset system ``` Set-SnipeitLocation [-id] [[-name] ] [[-address] ] [[-address2] ] [[-state] ] [[-country] ] [[-zip] ] [[-city] ] [[-currency] ] - [[-manager_id] ] [[-ldap_ou] ] [[-parent_id] ] [-url] [-apiKey] - [-WhatIf] [-Confirm] [] + [[-manager_id] ] [[-ldap_ou] ] [[-parent_id] ] [[-image] ] [-image_delete] + [-url] [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -70,7 +70,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 14 +Position: 15 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -136,6 +136,36 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 13 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -ldap_ou LDAP OU of Location @@ -220,7 +250,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 13 +Position: 14 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitModel.md b/docs/Set-SnipeitModel.md index 9397c5e..4890448 100644 --- a/docs/Set-SnipeitModel.md +++ b/docs/Set-SnipeitModel.md @@ -14,8 +14,8 @@ Updates Model on Snipe-it asset system ``` Set-SnipeitModel [-id] [[-name] ] [[-model_number] ] [[-category_id] ] - [[-manufacturer_id] ] [[-eol] ] [[-custom_fieldset_id] ] [-url] - [-apiKey] [-WhatIf] [-Confirm] [] + [[-manufacturer_id] ] [[-eol] ] [[-custom_fieldset_id] ] [[-image] ] + [-image_delete] [-url] [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -39,7 +39,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 9 +Position: 10 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -105,6 +105,36 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 8 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -manufacturer_id Manufacturer ID that the asset belongs to this can be got using Get-Manufacturer @@ -159,7 +189,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 8 +Position: 9 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitUser.md b/docs/Set-SnipeitUser.md index 1e52ef2..90fa582 100644 --- a/docs/Set-SnipeitUser.md +++ b/docs/Set-SnipeitUser.md @@ -16,8 +16,8 @@ Creates a new user Set-SnipeitUser [-id] [[-first_name] ] [[-last_name] ] [[-userName] ] [[-jobtitle] ] [[-email] ] [[-phone] ] [[-password] ] [[-company_id] ] [[-location_id] ] [[-department_id] ] [[-manager_id] ] [[-employee_num] ] - [[-activated] ] [[-notes] ] [-url] [-apiKey] [-WhatIf] [-Confirm] - [] + [[-activated] ] [[-notes] ] [[-image] ] [-image_delete] [-url] + [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -57,7 +57,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 17 +Position: 18 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -153,6 +153,36 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 16 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -jobtitle Users job tittle @@ -267,7 +297,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 16 +Position: 17 Default value: None Accept pipeline input: False Accept wildcard characters: False From 9b356a2b9eb82e82cea7b6839203f50d23e91773 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Fri, 9 Jul 2021 15:17:41 +0300 Subject: [PATCH 08/16] New/Set/Remove suppliers --- SnipeitPS/Public/New-SnipeitSupplier.ps1 | 117 +++++++ SnipeitPS/Public/Remove-SnipeitSupplier.ps1 | 54 ++++ SnipeitPS/Public/Set-SnipeitSupplier.ps1 | 134 ++++++++ SnipeitPS/SnipeitPS.psd1 | 3 + docs/New-SnipeitSupplier.md | 299 ++++++++++++++++++ docs/Remove-SnipeitSupplier.md | 122 ++++++++ docs/Set-SnipeitSupplier.md | 330 ++++++++++++++++++++ 7 files changed, 1059 insertions(+) create mode 100644 SnipeitPS/Public/New-SnipeitSupplier.ps1 create mode 100644 SnipeitPS/Public/Remove-SnipeitSupplier.ps1 create mode 100644 SnipeitPS/Public/Set-SnipeitSupplier.ps1 create mode 100644 docs/New-SnipeitSupplier.md create mode 100644 docs/Remove-SnipeitSupplier.md create mode 100644 docs/Set-SnipeitSupplier.md diff --git a/SnipeitPS/Public/New-SnipeitSupplier.ps1 b/SnipeitPS/Public/New-SnipeitSupplier.ps1 new file mode 100644 index 0000000..3bd64bf --- /dev/null +++ b/SnipeitPS/Public/New-SnipeitSupplier.ps1 @@ -0,0 +1,117 @@ +<# + .SYNOPSIS + Creates a supplier + + .DESCRIPTION + Creates a new supplier on Snipe-It system + + .PARAMETER name + Department Name + + .PARAMETER address + Address line 1 of supplier + + .PARAMETER address2 + Address line 1 of supplier + + .PARAMETER city + City + + .PARAMETER state + State + + .PARAMETER country + Country + + .PARAMETER zip + Zip code + + .PARAMETER phone + Phone number + + .PARAMETER fax + Fax number + + .PARAMETER email + Email address + + .PARAMETER contact + Contact person + + .PARAMETER notes + Email address + + .PARAMETER image + Image file name and path for item + + .PARAMETER url + URL of Snipeit system, can be set using Set-SnipeitInfo command + + .PARAMETER apiKey + Users API Key for Snipeit, can be set using Set-SnipeitInfo command + + .EXAMPLE + New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3 + +#> + +function New-SnipeitSupplier() { + [CmdletBinding( + SupportsShouldProcess = $true, + ConfirmImpact = "Low" + )] + + Param( + [parameter(mandatory = $true)] + [string]$name, + + [string]$address, + + [string]$address2, + + [string]$city, + + [string]$state, + + [string]$country, + + [string]$zip, + + [string]$phone, + + [string]$fax, + + [string]$email, + + [string]$contact, + + [string]$notes, + + [ValidateScript({Test-Path $_})] + [string]$image, + + [parameter(mandatory = $true)] + [string]$url, + + [parameter(mandatory = $true)] + [string]$apiKey + ) + + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + + $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + + $Parameters = @{ + Uri = "$url/api/v1/suppilers" + Method = 'POST' + Body = $Values + Token = $apiKey + } + + If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result +} + diff --git a/SnipeitPS/Public/Remove-SnipeitSupplier.ps1 b/SnipeitPS/Public/Remove-SnipeitSupplier.ps1 new file mode 100644 index 0000000..196df14 --- /dev/null +++ b/SnipeitPS/Public/Remove-SnipeitSupplier.ps1 @@ -0,0 +1,54 @@ +<# + .SYNOPSIS + Removes supplier from Snipe-it asset system + .DESCRIPTION + Removes supplier or multiple manufacturers from Snipe-it asset system + .PARAMETER ID + Unique ID For supplier to be removed + .PARAMETER url + URL of Snipeit system, can be set using Set-SnipeitInfo command + + .PARAMETER apiKey + User's API Key for Snipeit, can be set using Set-SnipeitInfo command + + .EXAMPLE + Remove-SnipeitSupplier -ID 44 + + .EXAMPLE + Get-SnipeitSupplier | Where-object {$_.name -like '*something*'} | Remove-SnipeitSupplier +#> + +function Remove-SnipeitSupplier () +{ + [CmdletBinding( + SupportsShouldProcess = $true, + ConfirmImpact = "Low" + )] + + Param( + [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] + [int[]]$id, + [parameter(mandatory = $true)] + [string]$URL, + [parameter(mandatory = $true)] + [string]$APIKey + + ) + begin { + } + process { + foreach($suppliers_id in $id){ + $Parameters = @{ + Uri = "$url/api/v1/suppliers/$supplier_id" + Method = 'Delete' + Token = $apiKey + } + + If ($PSCmdlet.ShouldProcess("ShouldProcess?")) + { + $result = Invoke-SnipeitMethod @Parameters + } + $result + } + } +} diff --git a/SnipeitPS/Public/Set-SnipeitSupplier.ps1 b/SnipeitPS/Public/Set-SnipeitSupplier.ps1 new file mode 100644 index 0000000..7180c5a --- /dev/null +++ b/SnipeitPS/Public/Set-SnipeitSupplier.ps1 @@ -0,0 +1,134 @@ +<# + .SYNOPSIS + Modify the supplier + + .DESCRIPTION + Modifieds the supplier on Snipe-It system + + .PARAMETER name + Suppiers Name + + .PARAMETER address + Address line 1 of supplier + + .PARAMETER address2 + Address line 1 of supplier + + .PARAMETER city + City + + .PARAMETER state + State + + .PARAMETER country + Country + + .PARAMETER zip + Zip code + + .PARAMETER phone + Phone number + + .PARAMETER fax + Fax number + + .PARAMETER email + Email address + + .PARAMETER contact + Contact person + + .PARAMETER notes + Email address + + .PARAMETER image + Image file name and path for item + + .PARAMETER image_delete + Remove current image + + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + + .PARAMETER url + URL of Snipeit system, can be set using Set-SnipeitInfo command + + .PARAMETER apiKey + Users API Key for Snipeit, can be set using Set-SnipeitInfo command + + .EXAMPLE + New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3 + +#> + +function Set-SnipeitSupplier() { + [CmdletBinding( + SupportsShouldProcess = $true, + ConfirmImpact = "Low" + )] + + Param( + [parameter(mandatory = $true)] + [string]$name, + + [string]$address, + + [string]$address2, + + [string]$city, + + [string]$state, + + [string]$country, + + [string]$zip, + + [string]$phone, + + [string]$fax, + + [string]$email, + + [string]$contact, + + [string]$notes, + + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete, + + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + + [parameter(mandatory = $true)] + [string]$url, + + [parameter(mandatory = $true)] + [string]$apiKey + ) + + begin { + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + + $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + + } + process { + foreach ($supplier_id in $id) { + $Parameters = @{ + Uri = "$url/api/v1/suppliers/$supplier_id" + Method = $RequestType + Body = $Values + Token = $apiKey + } + + If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result + } + } +} + diff --git a/SnipeitPS/SnipeitPS.psd1 b/SnipeitPS/SnipeitPS.psd1 index dbbb9ef..681fc36 100644 --- a/SnipeitPS/SnipeitPS.psd1 +++ b/SnipeitPS/SnipeitPS.psd1 @@ -104,6 +104,7 @@ FunctionsToExport = @( 'New-SnipeitLocation', 'New-SnipeitManufacturer', 'New-SnipeitModel', + 'New-SnipeitSupplier', 'New-SnipeitUser', 'Remove-SnipeitAccessory', 'Remove-SnipeitAsset', @@ -118,6 +119,7 @@ FunctionsToExport = @( 'Remove-SnipeitLocation', 'Remove-SnipeitManufacturer', 'Remove-SnipeitModel', + 'Remove-SnipeitSupplier', 'Remove-SnipeitUser', 'Reset-SnipeitAccessoryOwner', 'Reset-SnipeitAssetOwner', @@ -137,6 +139,7 @@ FunctionsToExport = @( 'Set-SnipeitLocation', 'Set-SnipeitModel', 'Set-SnipeitStatus', + 'Set-SnipeitSupplier', 'Set-SnipeitUser', 'Update-SnipeitAlias' ) diff --git a/docs/New-SnipeitSupplier.md b/docs/New-SnipeitSupplier.md new file mode 100644 index 0000000..670dfe5 --- /dev/null +++ b/docs/New-SnipeitSupplier.md @@ -0,0 +1,299 @@ +--- +external help file: SnipeitPS-help.xml +Module Name: SnipeitPS +online version: +schema: 2.0.0 +--- + +# New-SnipeitSupplier + +## SYNOPSIS +Creates a supplier + +## SYNTAX + +``` +New-SnipeitSupplier [-name] [[-address] ] [[-address2] ] [[-city] ] + [[-state] ] [[-country] ] [[-zip] ] [[-phone] ] [[-fax] ] + [[-email] ] [[-contact] ] [[-notes] ] [[-image] ] [-url] + [-apiKey] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Creates a new supplier on Snipe-It system + +## EXAMPLES + +### EXAMPLE 1 +``` +New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3 +``` + +## PARAMETERS + +### -address +Address line 1 of supplier + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -address2 +Address line 1 of supplier + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -apiKey +Users API Key for Snipeit, can be set using Set-SnipeitInfo command + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 15 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -city +City + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -contact +Contact person + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 11 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -country +Country + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 6 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -email +Email address + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 10 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -fax +Fax number + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 9 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 13 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -name +Department Name + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -notes +Email address + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 12 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -phone +Phone number + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 8 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -state +State + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 5 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -url +URL of Snipeit system, can be set using Set-SnipeitInfo command + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 14 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -zip +Zip code + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 7 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Remove-SnipeitSupplier.md b/docs/Remove-SnipeitSupplier.md new file mode 100644 index 0000000..031b2e8 --- /dev/null +++ b/docs/Remove-SnipeitSupplier.md @@ -0,0 +1,122 @@ +--- +external help file: SnipeitPS-help.xml +Module Name: SnipeitPS +online version: +schema: 2.0.0 +--- + +# Remove-SnipeitSupplier + +## SYNOPSIS +Removes supplier from Snipe-it asset system + +## SYNTAX + +``` +Remove-SnipeitSupplier [-id] [-URL] [-APIKey] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +Removes supplier or multiple manufacturers from Snipe-it asset system + +## EXAMPLES + +### EXAMPLE 1 +``` +Remove-SnipeitSupplier -ID 44 +``` + +### EXAMPLE 2 +``` +Get-SnipeitSupplier | Where-object {$_.name -like '*something*'} | Remove-SnipeitSupplier +``` + +## PARAMETERS + +### -APIKey +User's API Key for Snipeit, can be set using Set-SnipeitInfo command + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -id +Unique ID For supplier to be removed + +```yaml +Type: Int32[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -URL +URL of Snipeit system, can be set using Set-SnipeitInfo command + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-SnipeitSupplier.md b/docs/Set-SnipeitSupplier.md new file mode 100644 index 0000000..4cd4945 --- /dev/null +++ b/docs/Set-SnipeitSupplier.md @@ -0,0 +1,330 @@ +--- +external help file: SnipeitPS-help.xml +Module Name: SnipeitPS +online version: +schema: 2.0.0 +--- + +# Set-SnipeitSupplier + +## SYNOPSIS +Modify the supplier + +## SYNTAX + +``` +Set-SnipeitSupplier [-name] [[-address] ] [[-address2] ] [[-city] ] + [[-state] ] [[-country] ] [[-zip] ] [[-phone] ] [[-fax] ] + [[-email] ] [[-contact] ] [[-notes] ] [[-image] ] [-image_delete] + [[-RequestType] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Modifieds the supplier on Snipe-It system + +## EXAMPLES + +### EXAMPLE 1 +``` +New-SnipeitDepartment -name "Department1" -company_id 1 -localtion_id 1 -manager_id 3 +``` + +## PARAMETERS + +### -address +Address line 1 of supplier + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -address2 +Address line 1 of supplier + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -apiKey +Users API Key for Snipeit, can be set using Set-SnipeitInfo command + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 16 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -city +City + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -contact +Contact person + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 11 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -country +Country + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 6 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -email +Email address + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 10 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -fax +Fax number + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 9 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 13 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -name +Suppiers Name + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -notes +Email address + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 12 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -phone +Phone number + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 8 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -RequestType +Http request type to send Snipe IT system. +Defaults to Patch you could use Put if needed. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 14 +Default value: Patch +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -state +State + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 5 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -url +URL of Snipeit system, can be set using Set-SnipeitInfo command + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 15 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -zip +Zip code + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 7 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS From 989af1bf88ce846c114eaf23b7f7463bbef7a179 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Fri, 9 Jul 2021 21:17:25 +0300 Subject: [PATCH 09/16] corrected typo --- SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 b/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 index b9c109b..9605d9b 100644 --- a/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 @@ -39,7 +39,7 @@ function Remove-SnipeitManufacturer () process { foreach($manufacturer_id in $id){ $Parameters = @{ - Uri = "$url/api/v1/manufacturers/$manufacturer_id_id" + Uri = "$url/api/v1/manufacturers/$manufacturer_id" Method = 'Delete' Token = $apiKey } From bab98270fae88992c4dd97282065f66956af0395 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Fri, 9 Jul 2021 21:18:51 +0300 Subject: [PATCH 10/16] Added Set-SnipeitManufacturer --- SnipeitPS/Public/Set-SnipeitManufacturer.ps1 | 78 ++++++++++++++++++++ SnipeitPS/SnipeitPS.psd1 | 1 + 2 files changed, 79 insertions(+) create mode 100644 SnipeitPS/Public/Set-SnipeitManufacturer.ps1 diff --git a/SnipeitPS/Public/Set-SnipeitManufacturer.ps1 b/SnipeitPS/Public/Set-SnipeitManufacturer.ps1 new file mode 100644 index 0000000..d0c1064 --- /dev/null +++ b/SnipeitPS/Public/Set-SnipeitManufacturer.ps1 @@ -0,0 +1,78 @@ +<# + .SYNOPSIS + Add a new Manufacturer to Snipe-it asset system + + .DESCRIPTION + Long description + + .PARAMETER Name + Name of the Manufacturer + + .PARAMETER image + Image file name and path for item + + .PARAMETER image_delete + Remove current image + + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + + .PARAMETER url + URL of Snipeit system, can be set using Set-SnipeitInfo command + + .PARAMETER apiKey + Users API Key for Snipeit, can be set using Set-SnipeitInfo command + + .EXAMPLE + New-SnipeitManufacturer -name "HP" +#> + +function Set-SnipeitManufacturer() +{ + [CmdletBinding( + SupportsShouldProcess = $true, + ConfirmImpact = "Low" + )] + + Param( + [parameter(mandatory = $true)] + [string]$Name, + + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + + [parameter(mandatory = $true)] + [string]$url, + + [parameter(mandatory = $true)] + [string]$apiKey + ) + + begin{ + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + + $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + } + + process{ + foreach ($manufacturer_id in $id) { + $Parameters = @{ + Uri = "$url/api/v1/manufacturers/$manufacturer_id" + Method = $RequestType + Body = $Values + Token = $apiKey + } + + If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result + } + } +} diff --git a/SnipeitPS/SnipeitPS.psd1 b/SnipeitPS/SnipeitPS.psd1 index dbbb9ef..fb5fd68 100644 --- a/SnipeitPS/SnipeitPS.psd1 +++ b/SnipeitPS/SnipeitPS.psd1 @@ -135,6 +135,7 @@ FunctionsToExport = @( 'Set-SnipeitLicense', 'Set-SnipeitLicenseSeat', 'Set-SnipeitLocation', + 'Set-SnipeitManufacturer', 'Set-SnipeitModel', 'Set-SnipeitStatus', 'Set-SnipeitUser', From ccce2ab26ff0badebd4226bec9644389bd027c07 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Wed, 14 Jul 2021 10:53:22 +0300 Subject: [PATCH 11/16] image_delete does not make sense --- SnipeitPS/Public/New-SnipeitAccessory.ps1 | 7 +------ SnipeitPS/Public/New-SnipeitAsset.ps1 | 7 +------ SnipeitPS/Public/New-SnipeitCategory.ps1 | 7 +------ SnipeitPS/Public/New-SnipeitCompany.ps1 | 7 +------ SnipeitPS/Public/New-SnipeitComponent.ps1 | 7 +------ SnipeitPS/Public/New-SnipeitConsumable.ps1 | 7 +------ SnipeitPS/Public/New-SnipeitDepartment.ps1 | 5 +---- SnipeitPS/Public/New-SnipeitLocation.ps1 | 5 +---- SnipeitPS/Public/New-SnipeitManufacturer.ps1 | 2 +- SnipeitPS/Public/New-SnipeitModel.ps1 | 7 ++----- SnipeitPS/Public/New-SnipeitUser.ps1 | 7 +------ 11 files changed, 12 insertions(+), 56 deletions(-) diff --git a/SnipeitPS/Public/New-SnipeitAccessory.ps1 b/SnipeitPS/Public/New-SnipeitAccessory.ps1 index 0957c77..fa3616c 100644 --- a/SnipeitPS/Public/New-SnipeitAccessory.ps1 +++ b/SnipeitPS/Public/New-SnipeitAccessory.ps1 @@ -54,10 +54,7 @@ ID number of the location the accessory is assigned to Min quantity of the accessory before alert is triggered .PARAMETER image -Image file name and path for item - -.PARAMETER image_delete -Remove current image +Accessory image fileame and path .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -112,8 +109,6 @@ function New-SnipeitAccessory() { [ValidateScript({Test-Path $_})] [string]$image, - [switch]$image_delete=$false, - [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitAsset.ps1 b/SnipeitPS/Public/New-SnipeitAsset.ps1 index c0e7c4f..89c6ca9 100644 --- a/SnipeitPS/Public/New-SnipeitAsset.ps1 +++ b/SnipeitPS/Public/New-SnipeitAsset.ps1 @@ -43,10 +43,7 @@ Optional Purchase cost of the Asset Optional Default location id for the asset .PARAMETER image -Image file name and path for item - -.PARAMETER image_delete -Remove current image +Asset image filename and path .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -123,8 +120,6 @@ function New-SnipeitAsset() [ValidateScript({Test-Path $_})] [string]$image, - [switch]$image_delete=$false, - [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitCategory.ps1 b/SnipeitPS/Public/New-SnipeitCategory.ps1 index 2c61c49..f9e3741 100644 --- a/SnipeitPS/Public/New-SnipeitCategory.ps1 +++ b/SnipeitPS/Public/New-SnipeitCategory.ps1 @@ -21,10 +21,7 @@ If switch is present, require users to confirm acceptance of assets in this cate If switch is present, send email to user on checkin/checkout .PARAMETER image -Image file name and path for item - -.PARAMETER image_delete -Remove current image +Category image filename and path .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -62,8 +59,6 @@ function New-SnipeitCategory() [ValidateScript({Test-Path $_})] [string]$image, - [switch]$image_delete=$false, - [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitCompany.ps1 b/SnipeitPS/Public/New-SnipeitCompany.ps1 index 4bc41bf..2f25c34 100644 --- a/SnipeitPS/Public/New-SnipeitCompany.ps1 +++ b/SnipeitPS/Public/New-SnipeitCompany.ps1 @@ -9,10 +9,7 @@ Creates new company on Snipe-It system Comapany name .PARAMETER image -Image file name and path for item - -.PARAMETER image_delete -Remove current image +Company image filename and path .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -39,8 +36,6 @@ function New-SnipeitCompany() [ValidateScript({Test-Path $_})] [string]$image, - [switch]$image_delete=$false, - [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitComponent.ps1 b/SnipeitPS/Public/New-SnipeitComponent.ps1 index 7d75a19..194b46e 100644 --- a/SnipeitPS/Public/New-SnipeitComponent.ps1 +++ b/SnipeitPS/Public/New-SnipeitComponent.ps1 @@ -27,10 +27,7 @@ Date accessory was purchased Cost of item being purchased. .PARAMETER image -Image file name and path for item - -.PARAMETER image_delete -Remove current image +Component image filename and path .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -74,8 +71,6 @@ function New-SnipeitComponent() { [ValidateScript({Test-Path $_})] [string]$image, - [switch]$image_delete=$false, - [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitConsumable.ps1 b/SnipeitPS/Public/New-SnipeitConsumable.ps1 index 6ac6c5c..df2b594 100644 --- a/SnipeitPS/Public/New-SnipeitConsumable.ps1 +++ b/SnipeitPS/Public/New-SnipeitConsumable.ps1 @@ -45,10 +45,7 @@ Model number of the consumable in months Item number for the consumable .PARAMETER image -Image file name and path for item - -.PARAMETER image_delete -Remove current image +Consumable Image filename and path .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -113,8 +110,6 @@ function New-SnipeitConsumable() [ValidateScript({Test-Path $_})] [string]$image, - [switch]$image_delete=$false, - [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitDepartment.ps1 b/SnipeitPS/Public/New-SnipeitDepartment.ps1 index 5e5d337..185a165 100644 --- a/SnipeitPS/Public/New-SnipeitDepartment.ps1 +++ b/SnipeitPS/Public/New-SnipeitDepartment.ps1 @@ -18,10 +18,7 @@ ID number of manager .PARAMETER image - Image file name and path for item - - .PARAMETER image_delete - Remove current image + Department Image filename and path .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command diff --git a/SnipeitPS/Public/New-SnipeitLocation.ps1 b/SnipeitPS/Public/New-SnipeitLocation.ps1 index 32e858d..b34eaa3 100644 --- a/SnipeitPS/Public/New-SnipeitLocation.ps1 +++ b/SnipeitPS/Public/New-SnipeitLocation.ps1 @@ -39,10 +39,7 @@ The manager ID of the location .PARAMETER image - Image file name and path for item - - .PARAMETER image_delete - Remove current image + Location Image filename and path .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command diff --git a/SnipeitPS/Public/New-SnipeitManufacturer.ps1 b/SnipeitPS/Public/New-SnipeitManufacturer.ps1 index 1811aa9..67b5604 100644 --- a/SnipeitPS/Public/New-SnipeitManufacturer.ps1 +++ b/SnipeitPS/Public/New-SnipeitManufacturer.ps1 @@ -9,7 +9,7 @@ Name of the Manufacturer .PARAMETER image - Image file name and path for item + Manufacturer Image filename and path .PARAMETER image_delete Remove current image diff --git a/SnipeitPS/Public/New-SnipeitModel.ps1 b/SnipeitPS/Public/New-SnipeitModel.ps1 index 1480800..cc6b8f0 100644 --- a/SnipeitPS/Public/New-SnipeitModel.ps1 +++ b/SnipeitPS/Public/New-SnipeitModel.ps1 @@ -21,10 +21,9 @@ Fieldset ID that the asset uses (Custom fields) .PARAMETER image - Image file name and path for item + Asset model Image filename and path + - .PARAMETER image_delete - Remove current image .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -63,8 +62,6 @@ function New-SnipeitModel() [ValidateScript({Test-Path $_})] [string]$image, - [switch]$image_delete=$false, - [parameter(mandatory = $true)] [string]$url, diff --git a/SnipeitPS/Public/New-SnipeitUser.ps1 b/SnipeitPS/Public/New-SnipeitUser.ps1 index 138a377..61cbe36 100644 --- a/SnipeitPS/Public/New-SnipeitUser.ps1 +++ b/SnipeitPS/Public/New-SnipeitUser.ps1 @@ -51,10 +51,7 @@ Mark user as import from ldap .PARAMETER image - Image file name and path for item - - .PARAMETER image_delete - Remove current image + User Image file name and path .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -113,8 +110,6 @@ function New-SnipeitUser() { [ValidateScript({Test-Path $_})] [string]$image, - [switch]$image_delete=$false, - [parameter(mandatory = $true)] [string]$url, From fd2f5c51c70e5be3d2671d5c6facc86df2727f68 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Wed, 14 Jul 2021 11:09:12 +0300 Subject: [PATCH 12/16] Allow to set http request method --- SnipeitPS/Public/New-SnipeitModel.ps1 | 2 -- SnipeitPS/Public/Set-SnipeitAccessory.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitCategory.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitCompany.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitComponent.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitConsumable.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitCustomField.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitDepartment.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitLicense.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitLocation.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitModel.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitStatus.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitUser.ps1 | 6 ++++++ 14 files changed, 90 insertions(+), 14 deletions(-) diff --git a/SnipeitPS/Public/New-SnipeitModel.ps1 b/SnipeitPS/Public/New-SnipeitModel.ps1 index cc6b8f0..c15616e 100644 --- a/SnipeitPS/Public/New-SnipeitModel.ps1 +++ b/SnipeitPS/Public/New-SnipeitModel.ps1 @@ -23,8 +23,6 @@ .PARAMETER image Asset model Image filename and path - - .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command diff --git a/SnipeitPS/Public/Set-SnipeitAccessory.ps1 b/SnipeitPS/Public/Set-SnipeitAccessory.ps1 index 66032dc..cbb55d2 100644 --- a/SnipeitPS/Public/Set-SnipeitAccessory.ps1 +++ b/SnipeitPS/Public/Set-SnipeitAccessory.ps1 @@ -50,6 +50,9 @@ Image file name and path for item .PARAMETER image_delete Remove current image +.PARAMETER RequestType +Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command @@ -101,6 +104,9 @@ function Set-SnipeitAccessory() { [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -123,7 +129,7 @@ function Set-SnipeitAccessory() { foreach($accessory_id in $id){ $Parameters = @{ Uri = "$url/api/v1/accessories/$accessory_id" - Method = 'Patch' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitCategory.ps1 b/SnipeitPS/Public/Set-SnipeitCategory.ps1 index 33edafd..f10b21e 100644 --- a/SnipeitPS/Public/Set-SnipeitCategory.ps1 +++ b/SnipeitPS/Public/Set-SnipeitCategory.ps1 @@ -26,6 +26,9 @@ Image file name and path for item .PARAMETER image_delete Remove current image +.PARAMETER RequestType +Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -65,6 +68,9 @@ function Set-SnipeitCategory() [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -83,7 +89,7 @@ function Set-SnipeitCategory() foreach($category_id in $id){ $Parameters = @{ Uri = "$url/api/v1/categories/$category_id" - Method = 'Put' + Method = $RequestType Body = $values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitCompany.ps1 b/SnipeitPS/Public/Set-SnipeitCompany.ps1 index ee12e3c..923e76d 100644 --- a/SnipeitPS/Public/Set-SnipeitCompany.ps1 +++ b/SnipeitPS/Public/Set-SnipeitCompany.ps1 @@ -17,6 +17,9 @@ Image file name and path for item .PARAMETER image_delete Remove current image +.PARAMETER RequestType +Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -48,6 +51,9 @@ function Set-SnipeitCompany() [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -63,7 +69,7 @@ function Set-SnipeitCompany() foreach($company_id in $id){ $Parameters = @{ Uri = "$url/api/v1/companies/$company_id" - Method = 'Patch' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitComponent.ps1 b/SnipeitPS/Public/Set-SnipeitComponent.ps1 index e622a33..2834df9 100644 --- a/SnipeitPS/Public/Set-SnipeitComponent.ps1 +++ b/SnipeitPS/Public/Set-SnipeitComponent.ps1 @@ -38,6 +38,9 @@ Image file name and path for item .PARAMETER image_delete Remove current image +.PARAMETER RequestType +Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -84,6 +87,9 @@ function Set-SnipeitComponent() [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -104,7 +110,7 @@ function Set-SnipeitComponent() foreach($component_id in $id){ $Parameters = @{ Uri = "$url/api/v1/components/$component_id" - Method = 'Patch' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitConsumable.ps1 b/SnipeitPS/Public/Set-SnipeitConsumable.ps1 index 319ebf6..4aa28ab 100644 --- a/SnipeitPS/Public/Set-SnipeitConsumable.ps1 +++ b/SnipeitPS/Public/Set-SnipeitConsumable.ps1 @@ -53,6 +53,9 @@ Image file name and path for item .PARAMETER image_delete Remove current image +.PARAMETER RequestType +Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -123,6 +126,9 @@ function Set-SnipeitConsumable() [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -143,7 +149,7 @@ function Set-SnipeitConsumable() foreach($consumable_id in $id ){ $Parameters = @{ Uri = "$url/api/v1/consumables/$consumable_id" - Method = 'Put' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitCustomField.ps1 b/SnipeitPS/Public/Set-SnipeitCustomField.ps1 index d2dc817..d958d37 100644 --- a/SnipeitPS/Public/Set-SnipeitCustomField.ps1 +++ b/SnipeitPS/Public/Set-SnipeitCustomField.ps1 @@ -29,6 +29,9 @@ .PARAMETER help_text Any additional text you wish to display under the new form field to make it clearer what the gauges should be. + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Put you could use Patch if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -69,6 +72,9 @@ function Set-SnipeitCustomField() [string]$custom_format, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Put", + [parameter(mandatory = $true)] [string]$url, @@ -88,7 +94,7 @@ function Set-SnipeitCustomField() foreach($field_id in $id) { $Parameters = @{ Uri = "$url/api/v1/fields/$field_id" - Method = 'Put' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitDepartment.ps1 b/SnipeitPS/Public/Set-SnipeitDepartment.ps1 index 81bd7e0..09d4632 100644 --- a/SnipeitPS/Public/Set-SnipeitDepartment.ps1 +++ b/SnipeitPS/Public/Set-SnipeitDepartment.ps1 @@ -26,6 +26,9 @@ .PARAMETER image_delete Remove current image + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -62,6 +65,9 @@ function Set-SnipeitDepartment() { [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -78,7 +84,7 @@ function Set-SnipeitDepartment() { foreach ($department_id in $id) { $Parameters = @{ Uri = "$url/api/v1/departments/$department_id" - Method = 'Put' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitLicense.ps1 b/SnipeitPS/Public/Set-SnipeitLicense.ps1 index c853441..184aa57 100644 --- a/SnipeitPS/Public/Set-SnipeitLicense.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLicense.ps1 @@ -59,6 +59,9 @@ .PARAMETER termination_date Termination date for license. + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -121,6 +124,9 @@ function Set-SnipeitLicense() { [datetime]$termination_date, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -151,7 +157,7 @@ function Set-SnipeitLicense() { foreach($license_id in $id){ $Parameters = @{ Uri = "$url/api/v1/licenses/$license_id" - Method = 'PUT' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 b/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 index 838c652..5ef3880 100644 --- a/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 @@ -16,6 +16,9 @@ .PARAMETER note Notes about checkout + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -58,6 +61,9 @@ function Set-SnipeitLicenseSeat() [string]$note, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -73,7 +79,7 @@ function Set-SnipeitLicenseSeat() foreach($license_id in $id) { $Parameters = @{ Uri = "$url/api/v1/licenses/$license_id/seats/$seat_id" - Method = 'Patch' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitLocation.ps1 b/SnipeitPS/Public/Set-SnipeitLocation.ps1 index 8021ab9..b1c3770 100644 --- a/SnipeitPS/Public/Set-SnipeitLocation.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLocation.ps1 @@ -50,6 +50,9 @@ .PARAMETER image_delete Remove current image + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -99,6 +102,9 @@ function Set-SnipeitLocation() { [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -116,7 +122,7 @@ function Set-SnipeitLocation() { foreach ($location_id in $id) { $Parameters = @{ Uri = "$url/api/v1/locations/$location_id" - Method = 'PUT' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitModel.ps1 b/SnipeitPS/Public/Set-SnipeitModel.ps1 index 4d99df6..695368f 100644 --- a/SnipeitPS/Public/Set-SnipeitModel.ps1 +++ b/SnipeitPS/Public/Set-SnipeitModel.ps1 @@ -29,6 +29,9 @@ .PARAMETER image_delete Remove current image + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -68,6 +71,9 @@ function Set-SnipeitModel() { [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -85,7 +91,7 @@ function Set-SnipeitModel() { foreach ($model_id in $id) { $Parameters = @{ Uri = "$url/api/v1/models/$model_id" - Method = 'put' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitStatus.ps1 b/SnipeitPS/Public/Set-SnipeitStatus.ps1 index fe9867f..4c11b8a 100644 --- a/SnipeitPS/Public/Set-SnipeitStatus.ps1 +++ b/SnipeitPS/Public/Set-SnipeitStatus.ps1 @@ -15,6 +15,9 @@ Hex code showing what color the status label should be on the pie chart in the d .PARAMETER default_label 1 or 0 - determine whether it should be bubbled up to the top of the list of available statuses +.PARAMETER RequestType +Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -53,6 +56,9 @@ function Set-SnipeitStatus() [bool]$default_label, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -68,7 +74,7 @@ function Set-SnipeitStatus() foreach($status_id in $id) { $Parameters = @{ Uri = "$url/api/v1/statuslabels/$status_id" - Method = 'Put' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitUser.ps1 b/SnipeitPS/Public/Set-SnipeitUser.ps1 index 17e9662..8654f61 100644 --- a/SnipeitPS/Public/Set-SnipeitUser.ps1 +++ b/SnipeitPS/Public/Set-SnipeitUser.ps1 @@ -59,6 +59,9 @@ .PARAMETER image_delete Remove current image + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -118,6 +121,9 @@ function Set-SnipeitUser() { [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, From 7f6a5e1244917de08d0f601859fe3c7f026b860c Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Wed, 14 Jul 2021 11:16:55 +0300 Subject: [PATCH 13/16] Updated docs --- docs/New-SnipeitAccessory.md | 20 +--- docs/New-SnipeitAsset.md | 21 +--- docs/New-SnipeitCategory.md | 21 +--- docs/New-SnipeitCompany.md | 21 +--- docs/New-SnipeitComponent.md | 20 +--- docs/New-SnipeitConsumable.md | 21 +--- docs/New-SnipeitDepartment.md | 4 +- docs/New-SnipeitLocation.md | 4 +- docs/New-SnipeitManufacturer.md | 2 +- docs/New-SnipeitModel.md | 21 +--- docs/New-SnipeitSupplier.md | 2 +- docs/New-SnipeitUser.md | 21 +--- docs/Remove-SnipeitSupplier.md | 2 +- docs/Set-SnipeitAccessory.md | 24 ++++- docs/Set-SnipeitCategory.md | 24 ++++- docs/Set-SnipeitCompany.md | 24 ++++- docs/Set-SnipeitComponent.md | 24 ++++- docs/Set-SnipeitConsumable.md | 24 ++++- docs/Set-SnipeitCustomField.md | 23 ++++- docs/Set-SnipeitDepartment.md | 24 ++++- docs/Set-SnipeitLicense.md | 22 ++++- docs/Set-SnipeitLicenseSeat.md | 23 ++++- docs/Set-SnipeitLocation.md | 22 ++++- docs/Set-SnipeitManufacturer.md | 163 ++++++++++++++++++++++++++++++++ docs/Set-SnipeitModel.md | 23 ++++- docs/Set-SnipeitStatus.md | 24 ++++- docs/Set-SnipeitSupplier.md | 2 +- docs/Set-SnipeitUser.md | 24 ++++- docs/SnipeitPS.md | 12 +++ 29 files changed, 463 insertions(+), 199 deletions(-) create mode 100644 docs/Set-SnipeitManufacturer.md diff --git a/docs/New-SnipeitAccessory.md b/docs/New-SnipeitAccessory.md index b2fae75..27acd04 100644 --- a/docs/New-SnipeitAccessory.md +++ b/docs/New-SnipeitAccessory.md @@ -16,8 +16,7 @@ Creates new accessory on Snipe-It system New-SnipeitAccessory [-name] [-qty] [-category_id] [[-company_id] ] [[-manufacturer_id] ] [[-order_number] ] [[-model_number] ] [[-purchase_cost] ] [[-purchase_date] ] [[-min_amt] ] [[-supplier_id] ] [[-location_id] ] - [[-image] ] [-image_delete] [-url] [-apiKey] [-WhatIf] [-Confirm] - [] + [[-image] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -78,7 +77,7 @@ Accept wildcard characters: False ``` ### -image -Image file name and path for item +Accessory image fileame and path ```yaml Type: String @@ -92,21 +91,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -image_delete -Remove current image - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -location_id ID number of the location the accessory is assigned to diff --git a/docs/New-SnipeitAsset.md b/docs/New-SnipeitAsset.md index f1eedc1..907ab69 100644 --- a/docs/New-SnipeitAsset.md +++ b/docs/New-SnipeitAsset.md @@ -16,8 +16,8 @@ Add a new Asset to Snipe-it asset system New-SnipeitAsset [-status_id] [-model_id] [[-name] ] [[-asset_tag] ] [[-serial] ] [[-company_id] ] [[-order_number] ] [[-notes] ] [[-warranty_months] ] [[-purchase_cost] ] [[-purchase_date] ] - [[-supplier_id] ] [[-rtd_location_id] ] [[-image] ] [-image_delete] [-url] - [-apiKey] [[-customfields] ] [-WhatIf] [-Confirm] [] + [[-supplier_id] ] [[-rtd_location_id] ] [[-image] ] [-url] [-apiKey] + [[-customfields] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -107,7 +107,7 @@ Accept wildcard characters: False ``` ### -image -Image file name and path for item +Asset image filename and path ```yaml Type: String @@ -121,21 +121,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -image_delete -Remove current image - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -model_id Required Model ID of the asset, this can be got using Get-Model diff --git a/docs/New-SnipeitCategory.md b/docs/New-SnipeitCategory.md index e25ed93..927766d 100644 --- a/docs/New-SnipeitCategory.md +++ b/docs/New-SnipeitCategory.md @@ -14,8 +14,8 @@ Create a new Snipe-IT Category ``` New-SnipeitCategory [-name] [-category_type] [[-eula_text] ] [-use_default_eula] - [-require_acceptance] [-checkin_email] [[-image] ] [-image_delete] [-url] [-apiKey] - [-WhatIf] [-Confirm] [] + [-require_acceptance] [-checkin_email] [[-image] ] [-url] [-apiKey] [-WhatIf] + [-Confirm] [] ``` ## DESCRIPTION @@ -91,7 +91,7 @@ Accept wildcard characters: False ``` ### -image -Image file name and path for item +Category image filename and path ```yaml Type: String @@ -105,21 +105,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -image_delete -Remove current image - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -name Name of new category to be created diff --git a/docs/New-SnipeitCompany.md b/docs/New-SnipeitCompany.md index 667ca2f..320c3d9 100644 --- a/docs/New-SnipeitCompany.md +++ b/docs/New-SnipeitCompany.md @@ -13,8 +13,8 @@ Creates a new Company ## SYNTAX ``` -New-SnipeitCompany [-name] [[-image] ] [-image_delete] [-url] [-apiKey] - [-WhatIf] [-Confirm] [] +New-SnipeitCompany [-name] [[-image] ] [-url] [-apiKey] [-WhatIf] [-Confirm] + [] ``` ## DESCRIPTION @@ -45,7 +45,7 @@ Accept wildcard characters: False ``` ### -image -Image file name and path for item +Company image filename and path ```yaml Type: String @@ -59,21 +59,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -image_delete -Remove current image - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -name Comapany name diff --git a/docs/New-SnipeitComponent.md b/docs/New-SnipeitComponent.md index b00755b..3f230a2 100644 --- a/docs/New-SnipeitComponent.md +++ b/docs/New-SnipeitComponent.md @@ -15,8 +15,7 @@ Create a new component ``` New-SnipeitComponent [-name] [-category_id] [-qty] [[-company_id] ] [[-location_id] ] [[-order_number] ] [[-purchase_date] ] [[-purchase_cost] ] - [[-image] ] [-image_delete] [-url] [-apiKey] [-WhatIf] [-Confirm] - [] + [[-image] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -77,7 +76,7 @@ Accept wildcard characters: False ``` ### -image -Image file name and path for item +Component image filename and path ```yaml Type: String @@ -91,21 +90,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -image_delete -Remove current image - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -location_id ID number of the location the accessory is assigned to diff --git a/docs/New-SnipeitConsumable.md b/docs/New-SnipeitConsumable.md index 9fba0eb..4778e65 100644 --- a/docs/New-SnipeitConsumable.md +++ b/docs/New-SnipeitConsumable.md @@ -16,8 +16,8 @@ Add a new Consumable to Snipe-it asset system New-SnipeitConsumable [-name] [-qty] [-category_id] [[-min_amt] ] [[-company_id] ] [[-order_number] ] [[-manufacturer_id] ] [[-location_id] ] [[-requestable] ] [[-purchase_date] ] [[-purchase_cost] ] - [[-model_number] ] [[-item_no] ] [[-image] ] [-image_delete] [-url] - [-apiKey] [-WhatIf] [-Confirm] [] + [[-model_number] ] [[-item_no] ] [[-image] ] [-url] [-apiKey] + [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -79,7 +79,7 @@ Accept wildcard characters: False ``` ### -image -Image file name and path for item +Consumable Image filename and path ```yaml Type: String @@ -93,21 +93,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -image_delete -Remove current image - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -item_no Item number for the consumable diff --git a/docs/New-SnipeitDepartment.md b/docs/New-SnipeitDepartment.md index c60f4a5..cd96ed7 100644 --- a/docs/New-SnipeitDepartment.md +++ b/docs/New-SnipeitDepartment.md @@ -61,7 +61,7 @@ Accept wildcard characters: False ``` ### -image -Image file name and path for item +Department Image filename and path ```yaml Type: String @@ -76,7 +76,7 @@ Accept wildcard characters: False ``` ### -image_delete -Remove current image +{{ Fill image_delete Description }} ```yaml Type: SwitchParameter diff --git a/docs/New-SnipeitLocation.md b/docs/New-SnipeitLocation.md index 93c927d..744b3f2 100644 --- a/docs/New-SnipeitLocation.md +++ b/docs/New-SnipeitLocation.md @@ -122,7 +122,7 @@ Accept wildcard characters: False ``` ### -image -Image file name and path for item +Location Image filename and path ```yaml Type: String @@ -137,7 +137,7 @@ Accept wildcard characters: False ``` ### -image_delete -Remove current image +{{ Fill image_delete Description }} ```yaml Type: SwitchParameter diff --git a/docs/New-SnipeitManufacturer.md b/docs/New-SnipeitManufacturer.md index 2ed5dcb..d5e266a 100644 --- a/docs/New-SnipeitManufacturer.md +++ b/docs/New-SnipeitManufacturer.md @@ -45,7 +45,7 @@ Accept wildcard characters: False ``` ### -image -Image file name and path for item +Manufacturer Image filename and path ```yaml Type: String diff --git a/docs/New-SnipeitModel.md b/docs/New-SnipeitModel.md index d46eefb..564f431 100644 --- a/docs/New-SnipeitModel.md +++ b/docs/New-SnipeitModel.md @@ -14,8 +14,8 @@ Add a new Model to Snipe-it asset system ``` New-SnipeitModel [-name] [[-model_number] ] [-category_id] [-manufacturer_id] - [[-eol] ] [-fieldset_id] [[-image] ] [-image_delete] [-url] [-apiKey] - [-WhatIf] [-Confirm] [] + [[-eol] ] [-fieldset_id] [[-image] ] [-url] [-apiKey] [-WhatIf] + [-Confirm] [] ``` ## DESCRIPTION @@ -91,7 +91,7 @@ Accept wildcard characters: False ``` ### -image -Image file name and path for item +Asset model Image filename and path ```yaml Type: String @@ -105,21 +105,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -image_delete -Remove current image - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -manufacturer_id Manufacturer ID that the asset belongs to this can be got using Get-Manufacturer diff --git a/docs/New-SnipeitSupplier.md b/docs/New-SnipeitSupplier.md index 670dfe5..3892b88 100644 --- a/docs/New-SnipeitSupplier.md +++ b/docs/New-SnipeitSupplier.md @@ -1,4 +1,4 @@ ---- +--- external help file: SnipeitPS-help.xml Module Name: SnipeitPS online version: diff --git a/docs/New-SnipeitUser.md b/docs/New-SnipeitUser.md index 43c9334..e830d0a 100644 --- a/docs/New-SnipeitUser.md +++ b/docs/New-SnipeitUser.md @@ -16,8 +16,8 @@ Creates a new user New-SnipeitUser [-first_name] [-last_name] [-username] [[-password] ] [[-activated] ] [[-notes] ] [[-jobtitle] ] [[-email] ] [[-phone] ] [[-company_id] ] [[-location_id] ] [[-department_id] ] [[-manager_id] ] - [[-employee_num] ] [[-ldap_import] ] [[-image] ] [-image_delete] [-url] - [-apiKey] [-WhatIf] [-Confirm] [] + [[-employee_num] ] [[-ldap_import] ] [[-image] ] [-url] [-apiKey] + [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -139,7 +139,7 @@ Accept wildcard characters: False ``` ### -image -Image file name and path for item +User Image file name and path ```yaml Type: String @@ -153,21 +153,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -image_delete -Remove current image - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -jobtitle Users job tittle diff --git a/docs/Remove-SnipeitSupplier.md b/docs/Remove-SnipeitSupplier.md index 031b2e8..4fcae40 100644 --- a/docs/Remove-SnipeitSupplier.md +++ b/docs/Remove-SnipeitSupplier.md @@ -1,4 +1,4 @@ ---- +--- external help file: SnipeitPS-help.xml Module Name: SnipeitPS online version: diff --git a/docs/Set-SnipeitAccessory.md b/docs/Set-SnipeitAccessory.md index cc4b3eb..3d689f6 100644 --- a/docs/Set-SnipeitAccessory.md +++ b/docs/Set-SnipeitAccessory.md @@ -16,8 +16,8 @@ Updates accessory on Snipe-It system Set-SnipeitAccessory [-id] [[-name] ] [[-qty] ] [[-category_id] ] [[-company_id] ] [[-manufacturer_id] ] [[-model_number] ] [[-order_number] ] [[-purchase_cost] ] [[-purchase_date] ] [[-min_amt] ] [[-supplier_id] ] - [[-location_id] ] [[-image] ] [-image_delete] [-url] [-apiKey] [-WhatIf] - [-Confirm] [] + [[-location_id] ] [[-image] ] [-image_delete] [[-RequestType] ] [-url] + [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -41,7 +41,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 16 +Position: 17 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -257,6 +257,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -RequestType +Http request type to send Snipe IT system. +Defaults to Patch you could use Put if needed. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 15 +Default value: Patch +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -supplier_id ID number of the supplier for this accessory @@ -281,7 +297,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 15 +Position: 16 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitCategory.md b/docs/Set-SnipeitCategory.md index e78566c..ffa7b95 100644 --- a/docs/Set-SnipeitCategory.md +++ b/docs/Set-SnipeitCategory.md @@ -15,8 +15,8 @@ Create a new Snipe-IT Category ``` Set-SnipeitCategory [-id] [[-name] ] [[-category_type] ] [[-eula_text] ] [[-use_default_eula] ] [[-require_acceptance] ] [[-checkin_email] ] - [[-image] ] [-image_delete] [-url] [-apiKey] [-WhatIf] [-Confirm] - [] + [[-image] ] [-image_delete] [[-RequestType] ] [-url] [-apiKey] [-WhatIf] + [-Confirm] [] ``` ## DESCRIPTION @@ -40,7 +40,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 10 +Position: 11 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -151,6 +151,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -RequestType +Http request type to send Snipe IT system. +Defaults to Patch you could use Put if needed. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 9 +Default value: Patch +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -require_acceptance If switch is present, require users to confirm acceptance of assets in this category @@ -175,7 +191,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 9 +Position: 10 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitCompany.md b/docs/Set-SnipeitCompany.md index d23077a..6c32fed 100644 --- a/docs/Set-SnipeitCompany.md +++ b/docs/Set-SnipeitCompany.md @@ -13,8 +13,8 @@ Updates company name ## SYNTAX ``` -Set-SnipeitCompany [-id] [-name] [[-image] ] [-image_delete] [-url] - [-apiKey] [-WhatIf] [-Confirm] [] +Set-SnipeitCompany [-id] [-name] [[-image] ] [-image_delete] + [[-RequestType] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -38,7 +38,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 5 +Position: 6 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -104,6 +104,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -RequestType +Http request type to send Snipe IT system. +Defaults to Patch you could use Put if needed. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: Patch +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -113,7 +129,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 4 +Position: 5 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitComponent.md b/docs/Set-SnipeitComponent.md index b2cc8ad..38312ae 100644 --- a/docs/Set-SnipeitComponent.md +++ b/docs/Set-SnipeitComponent.md @@ -15,8 +15,8 @@ Updates component ``` Set-SnipeitComponent [-id] [-qty] [[-min_amt] ] [[-name] ] [[-company_id] ] [[-location_id] ] [[-order_number] ] [[-purchase_date] ] - [[-purchase_cost] ] [[-image] ] [-image_delete] [-url] [-apiKey] [-WhatIf] - [-Confirm] [] + [[-purchase_cost] ] [[-image] ] [-image_delete] [[-RequestType] ] [-url] + [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -40,7 +40,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 12 +Position: 13 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -211,6 +211,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -RequestType +Http request type to send Snipe IT system. +Defaults to Patch you could use Put if needed. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 11 +Default value: Patch +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -220,7 +236,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 11 +Position: 12 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitConsumable.md b/docs/Set-SnipeitConsumable.md index ecdde9c..ec673c0 100644 --- a/docs/Set-SnipeitConsumable.md +++ b/docs/Set-SnipeitConsumable.md @@ -16,8 +16,8 @@ Add a new Consumable to Snipe-it asset system Set-SnipeitConsumable [-id] [[-name] ] [[-qty] ] [[-category_id] ] [[-min_amt] ] [[-company_id] ] [[-order_number] ] [[-manufacturer_id] ] [[-location_id] ] [[-requestable] ] [[-purchase_date] ] [[-purchase_cost] ] - [[-model_number] ] [[-item_no] ] [[-image] ] [-image_delete] [-url] - [-apiKey] [-WhatIf] [-Confirm] [] + [[-model_number] ] [[-item_no] ] [[-image] ] [-image_delete] [[-RequestType] ] + [-url] [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -42,7 +42,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 17 +Position: 18 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -288,6 +288,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -RequestType +Http request type to send Snipe IT system. +Defaults to Patch you could use Put if needed. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 16 +Default value: Patch +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -297,7 +313,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 16 +Position: 17 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitCustomField.md b/docs/Set-SnipeitCustomField.md index 78fe1f3..8606f6d 100644 --- a/docs/Set-SnipeitCustomField.md +++ b/docs/Set-SnipeitCustomField.md @@ -15,7 +15,8 @@ Add a new Custom Field to Snipe-it asset system ``` Set-SnipeitCustomField [-id] [[-name] ] [[-help_text] ] [-element] [[-format] ] [[-field_values] ] [[-field_encrypted] ] [[-show_in_email] ] - [[-custom_format] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-custom_format] ] [[-RequestType] ] [-url] [-apiKey] [-WhatIf] [-Confirm] + [] ``` ## DESCRIPTION @@ -39,7 +40,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 11 +Position: 12 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -166,6 +167,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -RequestType +Http request type to send Snipe IT system. +Defaults to Put you could use Patch if needed. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 10 +Default value: Put +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -show_in_email Whether or not to show the custom field in email notifications @@ -190,7 +207,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 10 +Position: 11 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitDepartment.md b/docs/Set-SnipeitDepartment.md index ca6e6a1..e3de315 100644 --- a/docs/Set-SnipeitDepartment.md +++ b/docs/Set-SnipeitDepartment.md @@ -14,8 +14,8 @@ Updates a department ``` Set-SnipeitDepartment [-id] [[-name] ] [[-company_id] ] [[-location_id] ] - [[-manager_id] ] [[-notes] ] [[-image] ] [-image_delete] [-url] - [-apiKey] [-WhatIf] [-Confirm] [] + [[-manager_id] ] [[-notes] ] [[-image] ] [-image_delete] [[-RequestType] ] + [-url] [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -39,7 +39,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 9 +Position: 10 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -165,6 +165,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -RequestType +Http request type to send Snipe IT system. +Defaults to Patch you could use Put if needed. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 8 +Default value: Patch +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -174,7 +190,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 8 +Position: 9 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitLicense.md b/docs/Set-SnipeitLicense.md index 8730895..00a36ea 100644 --- a/docs/Set-SnipeitLicense.md +++ b/docs/Set-SnipeitLicense.md @@ -18,7 +18,7 @@ Set-SnipeitLicense [-id] [[-name] ] [[-seats] ] [[-cate [[-license_name] ] [[-maintained] ] [[-manufacturer_id] ] [[-notes] ] [[-order_number] ] [[-purchase_cost] ] [[-purchase_date] ] [[-reassignable] ] [[-serial] ] [[-supplier_id] ] [[-termination_date] ] - [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-RequestType] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -42,7 +42,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 20 +Position: 21 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -258,6 +258,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -RequestType +Http request type to send Snipe IT system. +Defaults to Patch you could use Put if needed. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 19 +Default value: Patch +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -seats Number of license seats owned. @@ -327,7 +343,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 19 +Position: 20 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitLicenseSeat.md b/docs/Set-SnipeitLicenseSeat.md index 7f53a74..f8ba02b 100644 --- a/docs/Set-SnipeitLicenseSeat.md +++ b/docs/Set-SnipeitLicenseSeat.md @@ -14,7 +14,8 @@ Set license seat or checkout license seat ``` Set-SnipeitLicenseSeat [-id] [-seat_id] [[-assigned_to] ] [[-asset_id] ] - [[-note] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-note] ] [[-RequestType] ] [-url] [-apiKey] [-WhatIf] [-Confirm] + [] ``` ## DESCRIPTION @@ -51,7 +52,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 7 +Position: 8 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -117,6 +118,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -RequestType +Http request type to send Snipe IT system. +Defaults to Patch you could use Put if needed. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 6 +Default value: Patch +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -seat_id {{ Fill seat_id Description }} @@ -141,7 +158,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 6 +Position: 7 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitLocation.md b/docs/Set-SnipeitLocation.md index 4a8b9f1..c1ffa14 100644 --- a/docs/Set-SnipeitLocation.md +++ b/docs/Set-SnipeitLocation.md @@ -16,7 +16,7 @@ Updates Location in Snipe-it asset system Set-SnipeitLocation [-id] [[-name] ] [[-address] ] [[-address2] ] [[-state] ] [[-country] ] [[-zip] ] [[-city] ] [[-currency] ] [[-manager_id] ] [[-ldap_ou] ] [[-parent_id] ] [[-image] ] [-image_delete] - [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [[-RequestType] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -70,7 +70,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 15 +Position: 16 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -226,6 +226,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -RequestType +Http request type to send Snipe IT system. +Defaults to Patch you could use Put if needed. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 14 +Default value: Patch +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -state Address State @@ -250,7 +266,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 14 +Position: 15 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitManufacturer.md b/docs/Set-SnipeitManufacturer.md new file mode 100644 index 0000000..18ea40e --- /dev/null +++ b/docs/Set-SnipeitManufacturer.md @@ -0,0 +1,163 @@ +--- +external help file: SnipeitPS-help.xml +Module Name: SnipeitPS +online version: +schema: 2.0.0 +--- + +# Set-SnipeitManufacturer + +## SYNOPSIS +Add a new Manufacturer to Snipe-it asset system + +## SYNTAX + +``` +Set-SnipeitManufacturer [-Name] [[-image] ] [-image_delete] [[-RequestType] ] + [-url] [-apiKey] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Long description + +## EXAMPLES + +### EXAMPLE 1 +``` +New-SnipeitManufacturer -name "HP" +``` + +## PARAMETERS + +### -apiKey +Users API Key for Snipeit, can be set using Set-SnipeitInfo command + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 5 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image +Image file name and path for item + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -image_delete +Remove current image + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +Name of the Manufacturer + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -RequestType +Http request type to send Snipe IT system. +Defaults to Patch you could use Put if needed. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: Patch +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -url +URL of Snipeit system, can be set using Set-SnipeitInfo command + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 4 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-SnipeitModel.md b/docs/Set-SnipeitModel.md index 4890448..41bb999 100644 --- a/docs/Set-SnipeitModel.md +++ b/docs/Set-SnipeitModel.md @@ -15,7 +15,8 @@ Updates Model on Snipe-it asset system ``` Set-SnipeitModel [-id] [[-name] ] [[-model_number] ] [[-category_id] ] [[-manufacturer_id] ] [[-eol] ] [[-custom_fieldset_id] ] [[-image] ] - [-image_delete] [-url] [-apiKey] [-WhatIf] [-Confirm] [] + [-image_delete] [[-RequestType] ] [-url] [-apiKey] [-WhatIf] [-Confirm] + [] ``` ## DESCRIPTION @@ -39,7 +40,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 10 +Position: 11 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -180,6 +181,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -RequestType +Http request type to send Snipe IT system. +Defaults to Patch you could use Put if needed. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 9 +Default value: Patch +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -189,7 +206,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 9 +Position: 10 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitStatus.md b/docs/Set-SnipeitStatus.md index 2e23b50..e8f37c0 100644 --- a/docs/Set-SnipeitStatus.md +++ b/docs/Set-SnipeitStatus.md @@ -14,8 +14,8 @@ Sets Snipe-it Status Labels ``` Set-SnipeitStatus [-id] [[-name] ] [-type] [[-notes] ] [[-color] ] - [[-show_in_nav] ] [[-default_label] ] [-url] [-apiKey] [-WhatIf] - [-Confirm] [] + [[-show_in_nav] ] [[-default_label] ] [[-RequestType] ] [-url] + [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -44,7 +44,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 9 +Position: 10 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -125,6 +125,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -RequestType +Http request type to send Snipe IT system. +Defaults to Patch you could use Put if needed. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 8 +Default value: Patch +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -show_in_nav 1 or 0 - determine whether the status label should show in the left-side nav of the web GUI @@ -164,7 +180,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 8 +Position: 9 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/Set-SnipeitSupplier.md b/docs/Set-SnipeitSupplier.md index 4cd4945..c1e35e6 100644 --- a/docs/Set-SnipeitSupplier.md +++ b/docs/Set-SnipeitSupplier.md @@ -1,4 +1,4 @@ ---- +--- external help file: SnipeitPS-help.xml Module Name: SnipeitPS online version: diff --git a/docs/Set-SnipeitUser.md b/docs/Set-SnipeitUser.md index 90fa582..d2ca9f5 100644 --- a/docs/Set-SnipeitUser.md +++ b/docs/Set-SnipeitUser.md @@ -16,8 +16,8 @@ Creates a new user Set-SnipeitUser [-id] [[-first_name] ] [[-last_name] ] [[-userName] ] [[-jobtitle] ] [[-email] ] [[-phone] ] [[-password] ] [[-company_id] ] [[-location_id] ] [[-department_id] ] [[-manager_id] ] [[-employee_num] ] - [[-activated] ] [[-notes] ] [[-image] ] [-image_delete] [-url] - [-apiKey] [-WhatIf] [-Confirm] [] + [[-activated] ] [[-notes] ] [[-image] ] [-image_delete] [[-RequestType] ] + [-url] [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -57,7 +57,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 18 +Position: 19 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -288,6 +288,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -RequestType +Http request type to send Snipe IT system. +Defaults to Patch you could use Put if needed. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 17 +Default value: Patch +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -297,7 +313,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 17 +Position: 18 Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/SnipeitPS.md b/docs/SnipeitPS.md index aba8a60..2378a40 100644 --- a/docs/SnipeitPS.md +++ b/docs/SnipeitPS.md @@ -104,6 +104,9 @@ Add a new Manufacturer to Snipe-it asset system ### [New-SnipeitModel](New-SnipeitModel.md) Add a new Model to Snipe-it asset system +### [New-SnipeitSupplier](New-SnipeitSupplier.md) +Creates a supplier + ### [New-SnipeitUser](New-SnipeitUser.md) Creates a new user @@ -146,6 +149,9 @@ Removes manufacturer from Snipe-it asset system ### [Remove-SnipeitModel](Remove-SnipeitModel.md) Removes Asset model from Snipe-it asset system +### [Remove-SnipeitSupplier](Remove-SnipeitSupplier.md) +Removes supplier from Snipe-it asset system + ### [Remove-SnipeitUser](Remove-SnipeitUser.md) Removes User from Snipe-it asset system @@ -197,12 +203,18 @@ Set license seat or checkout license seat ### [Set-SnipeitLocation](Set-SnipeitLocation.md) Updates Location in Snipe-it asset system +### [Set-SnipeitManufacturer](Set-SnipeitManufacturer.md) +Add a new Manufacturer to Snipe-it asset system + ### [Set-SnipeitModel](Set-SnipeitModel.md) Updates Model on Snipe-it asset system ### [Set-SnipeitStatus](Set-SnipeitStatus.md) Sets Snipe-it Status Labels +### [Set-SnipeitSupplier](Set-SnipeitSupplier.md) +Modify the supplier + ### [Set-SnipeitUser](Set-SnipeitUser.md) Creates a new user From 464c9430f783b652ae1dc9aa0c44cf95d3a22d12 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Wed, 14 Jul 2021 11:59:33 +0300 Subject: [PATCH 14/16] Updated docs --- CHANGELOG.md | 19 +++++++++++++++++++ SnipeitPS/SnipeitPS.psd1 | 2 +- appveyor.yml | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b27a3c4..e26f8f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/), and this project adheres to [Semantic Versioning](http://semver.org/). +# [v.1.9.x] - 2021-07-14 + +## Image uploads + +## New features +Support for image upload and removes. Just specify filename for -image para- +meter to upload image when creating or updating item on snipe. +to remove image use -image_delete parameter + +Most of set-commands have new -RequestType parameter that defaults to Patch. +If needed request method can be changed from default. + +## New Functions +Following new commands have been added to SnipeitPS: +- New-Supplier +- Set-Supplier +- Remove-Supplier +- Set-Manufacturer + # [v.1.8.x] - 2021-06-17 diff --git a/SnipeitPS/SnipeitPS.psd1 b/SnipeitPS/SnipeitPS.psd1 index 3402561..0f0201c 100644 --- a/SnipeitPS/SnipeitPS.psd1 +++ b/SnipeitPS/SnipeitPS.psd1 @@ -12,7 +12,7 @@ RootModule = 'SnipeitPS' # Version number of this module. -ModuleVersion = '1.8' +ModuleVersion = '1.9' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/appveyor.yml b/appveyor.yml index a316978..dc61a6c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,7 +17,7 @@ environment: secure: UdM6qhf5B0G8liHhUrwWERCZr44iSqmg4jUq0lwlTjZs4KyeoiwnBzdej0phqIAm PShell: '5' -version: 1.8.{build} +version: 1.9.{build} # Don't rebuild when I tag a release on GitHub skip_tags: true From ec3b9b497296b4cddda2f1ee4df72e4b3b2f590e Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Wed, 14 Jul 2021 12:08:38 +0300 Subject: [PATCH 15/16] Updated docs --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e26f8f7..e2abdaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## New features Support for image upload and removes. Just specify filename for -image para- -meter to upload image when creating or updating item on snipe. -to remove image use -image_delete parameter +meter when creating or updating item on snipe. +Remove image use -image_delete parameter. + +*Snipe It version greater than 5.1.8 is needed to support image parameters.* Most of set-commands have new -RequestType parameter that defaults to Patch. If needed request method can be changed from default. From ae68666bbd34f7fc482a403cbe43a6fa0230beb9 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Wed, 14 Jul 2021 13:01:56 +0300 Subject: [PATCH 16/16] Add _method and use always post with multipart/form-data --- SnipeitPS/Private/Invoke-SnipeitMethod.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 index 8e9ac84..4f8f26d 100644 --- a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 +++ b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 @@ -61,11 +61,15 @@ ErrorAction = 'SilentlyContinue' } - #Place holder for intended image manipulation + # Place holder for intended image manipulation # if and when snipe it API gets support for images if($null -ne $body -and $Body.Keys -contains 'image' ){ if($PSVersionTable.PSVersion -ge '7.0'){ $Body['image'] = get-item $body['image'] + # As multipart/form-data is always POST we need add + # requested method for laravel named as '_method' + $Body['_method'] = $Method + $splatParameters["Method"] = 'POST' $splatParameters["Form"] = $Body } else { # use base64 encoded images for powershell version < 7