Public/Set-SnipeItAccessory.ps1
<# .SYNOPSIS Updates accessory on Snipe-It system .DESCRIPTION Updates accessory on Snipe-It system .PARAMETER name ID number of Accessory on Snipe-It system .PARAMETER qty Quantity of the accessory you have .PARAMETER category_id ID number of the category the accessory belongs to .PARAMETER company_id ID Number of the company the accessory is assigned to .PARAMETER manufacturer_id ID number of the manufacturer for this accessory. .PARAMETER order_number Order number for this accessory. .PARAMETER purchase_cost 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 .PARAMETER apiKey Users API Key for Snipeit, can be set using Set-SnipeItInfoeItInfoeItInfo command .EXAMPLE Set-SnipeItAccessory -id 1 -qty 3 #> function Set-SnipeItAccessory() { [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Low" )] Param( [parameter(mandatory = $true)] [int]$id, [ValidateLength(3, 255)] [string]$name, [int]$qty, [ValidateRange(1, [int]::MaxValue)] [int]$category_id, [ValidateRange(1, [int]::MaxValue)] [int]$company_id, [ValidateRange(1, [int]::MaxValue)] [int]$manufacturer_id, [string]$order_number, [float]$purchase_cost, [datetime]$purchase_date, [bool]$min_qty, [ValidateRange(1, [int]::MaxValue)] [int]$supplier_id, [parameter(mandatory = $true)] [string]$url, [parameter(mandatory = $true)] [string]$apiKey ) Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name $Values = . Get-ParameterValue $MyInvocation.MyCommand.Parameters if ($values['purchase_date']) { $values['purchase_date'] = $values['purchase_date'].ToString("yyyy-MM-dd") } $Body = $Values | ConvertTo-Json; $Parameters = @{ Uri = "$url/api/v1/accessories/$id" Method = 'POST' Body = $Body Token = $apiKey } If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } |