SnipeitPS/SnipeitPS/Public/New-SnipeItAccessory.ps1

127 lines
2.6 KiB
PowerShell
Raw Normal View History

2021-05-19 15:51:49 +03:00
<#
.SYNOPSIS
Creates new accessory on Snipe-It system
2021-05-19 15:51:49 +03:00
.DESCRIPTION
Creates new accessory on Snipe-It system
.PARAMETER name
Accessory name
.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-SnipeItInfo command
2021-05-19 15:51:49 +03:00
.PARAMETER apiKey
Users API Key for Snipeit, can be set using Set-SnipeItInfo command
2021-05-19 15:51:49 +03:00
.EXAMPLE
New-Accessory -name "Accessory" -qty 3 -category_id 1
#>
function New-SnipeItAccessory() {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true)]
[ValidateLength(3, 255)]
[string]$name,
[parameter(mandatory = $true)]
[int]$qty,
[parameter(mandatory = $true)]
[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,
2021-05-19 15:51:49 +03:00
[int]$min_qty,
[ValidateRange(1, [int]::MaxValue)]
[int]$supplier_id,
2021-05-19 15:51:49 +03:00
[ValidateRange(1, [int]::MaxValue)]
[int]$location_id,
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $true)]
[string]$apiKey
)
2021-01-29 18:08:19 +02:00
$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"
Method = 'POST'
Body = $Body
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
$result = Invoke-SnipeitMethod @Parameters
}
$result
}