SnipeitPS/SnipeitPS/Public/Set-Accessory.ps1

65 lines
1.3 KiB
PowerShell

function Set-Accessory() {
[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]$requestable,
[ValidateRange(1, [int]::MaxValue)]
[int]$supplier_id,
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $true)]
[string]$apiKey
)
$Values = . Get-ParameterValue
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
}