mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 18:02:30 +00:00
Merge pull request #191 from PetriAsi/feature/support-images
Starting adding support for images and cleaning up requests generation
This commit is contained in:
commit
44a5886f09
50 changed files with 130 additions and 166 deletions
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
# Body of the request
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Body,
|
||||
[Hashtable]$Body,
|
||||
|
||||
[string] $Token,
|
||||
|
||||
|
|
@ -34,6 +34,8 @@
|
|||
Throw $exception
|
||||
}
|
||||
|
||||
#To support images "image" property have be handled before this
|
||||
|
||||
$_headers = @{
|
||||
"Authorization" = "Bearer $($token)"
|
||||
'Content-Type' = 'application/json; charset=utf-8'
|
||||
|
|
@ -57,19 +59,34 @@
|
|||
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
|
||||
|
||||
Write-Debug $Body
|
||||
Write-Debug "$($Body | ConvertTo-Json)"
|
||||
|
||||
# Invoke the API
|
||||
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"
|
||||
|
|
@ -81,30 +98,43 @@
|
|||
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
|
||||
#update operations return payload
|
||||
if ($webResponse.payload){
|
||||
$result = $webResponse.payload
|
||||
}
|
||||
elseif (($response) -and ($response | Get-Member -Name rows)) {
|
||||
$result = $response.rows
|
||||
#Search operations return rows
|
||||
elseif ($webResponse.rows) {
|
||||
$result = $webResponse.rows
|
||||
}
|
||||
#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 {
|
||||
|
|
|
|||
|
|
@ -221,7 +221,6 @@ function Get-SnipeitAsset() {
|
|||
'Assets with component id' {$apiurl = "$url/api/v1/components/$component_id/assets"}
|
||||
}
|
||||
|
||||
|
||||
$Parameters = @{
|
||||
Uri = $apiurl
|
||||
Method = 'Get'
|
||||
|
|
|
|||
|
|
@ -118,12 +118,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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,12 +120,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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ function Remove-SnipeitAccessory ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/accessories/$accessory_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ function Remove-SnipeitAsset ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/hardware/$asset_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ function Remove-SnipeitAssetMaintenance {
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/maintenances/$maintenance_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ function Remove-SnipeitCategory ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/categories/$category_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ function Remove-SnipeitCompany ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/companies/$company_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ function Remove-SnipeitComponent ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/components/$component_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ function Remove-SnipeitConsumable ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/consumables/$consumable_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ function Remove-SnipeitCustomField ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/fields/$field_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ function Remove-SnipeitDepartment ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/departments/$department_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ function Remove-SnipeitLicense ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/licenses/$license_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ function Remove-SnipeitLocation ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/locations/$asset_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ function Remove-SnipeitManufacturer ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/manufacturers/$manufacturer_id_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ function Remove-SnipeitModel ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/models/$model_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ function Remove-SnipeitUser ()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/users/$user_id"
|
||||
Method = 'Delete'
|
||||
Body = '{}'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ function Reset-SnipeitAccessoryOwner()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/accessories/$assigned_pivot_id/checkin"
|
||||
Method = 'Post'
|
||||
Body = '{}'
|
||||
Body = @{}
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
||||
|
|
@ -112,20 +102,18 @@ 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 {
|
||||
foreach($accessory_id in $id){
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/accessories/$accessory_id"
|
||||
Method = 'Put'
|
||||
Body = $Body
|
||||
Method = 'Patch'
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,8 +136,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)
|
||||
|
|
@ -145,7 +145,6 @@ function Set-SnipeitAsset()
|
|||
$Values += $customfields
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
}
|
||||
|
||||
process {
|
||||
|
|
@ -153,7 +152,7 @@ function Set-SnipeitAsset()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/hardware/$asset_id"
|
||||
Method = $RequestType
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,13 +82,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 {
|
||||
|
|
@ -96,7 +94,7 @@ function Set-SnipeitComponent()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/components/$component_id"
|
||||
Method = 'Patch'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,6 @@ function Set-SnipeitConsumable()
|
|||
$Values['purchase_date'] = $Values['purchase_date'].ToString("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
}
|
||||
|
||||
process {
|
||||
|
|
@ -134,7 +133,7 @@ function Set-SnipeitConsumable()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/consumables/$consumable_id"
|
||||
Method = 'Put'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,19 +133,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 {
|
||||
|
|
@ -153,7 +152,7 @@ function Set-SnipeitLicense() {
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/licenses/$license_id"
|
||||
Method = 'PUT'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,8 +50,10 @@ function Set-SnipeitLicenseSeat()
|
|||
[int]$seat_id,
|
||||
|
||||
[Alias('assigned_id')]
|
||||
|
||||
[Nullable[System.Int32]]$assigned_to,
|
||||
|
||||
|
||||
[Nullable[System.Int32]]$asset_id,
|
||||
|
||||
[string]$note,
|
||||
|
|
@ -65,8 +67,6 @@ function Set-SnipeitLicenseSeat()
|
|||
|
||||
begin{
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
}
|
||||
|
||||
process{
|
||||
|
|
@ -74,7 +74,7 @@ function Set-SnipeitLicenseSeat()
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/licenses/$license_id/seats/$seat_id"
|
||||
Method = 'Patch'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,14 +69,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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,6 @@ function Set-SnipeitUser() {
|
|||
$Values['password_confirmation'] = $password
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
}
|
||||
|
||||
process{
|
||||
|
|
@ -130,7 +129,7 @@ function Set-SnipeitUser() {
|
|||
$Parameters = @{
|
||||
Uri = "$url/api/v1/users/$user_id"
|
||||
Method = 'PATCH'
|
||||
Body = $Body
|
||||
Body = $Values
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ Updates accessory on Snipe-It system
|
|||
Set-SnipeitAccessory [-id] <Int32[]> [[-name] <String>] [[-qty] <Int32>] [[-category_id] <Int32>]
|
||||
[[-company_id] <Int32>] [[-manufacturer_id] <Int32>] [[-model_number] <String>] [[-order_number] <String>]
|
||||
[[-purchase_cost] <Single>] [[-purchase_date] <DateTime>] [[-min_amt] <Int32>] [[-supplier_id] <Int32>]
|
||||
[-url] <String> [-apiKey] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
|
||||
[[-location_id] <Int32>] [-url] <String> [-apiKey] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
|
||||
```
|
||||
|
||||
## 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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue