mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 18:02:30 +00:00
82 lines
1.4 KiB
PowerShell
82 lines
1.4 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Short description
|
|
|
|
.DESCRIPTION
|
|
Long description
|
|
|
|
.PARAMETER name
|
|
Parameter description
|
|
|
|
.PARAMETER category_id
|
|
Parameter description
|
|
|
|
.PARAMETER qty
|
|
Parameter description
|
|
|
|
.PARAMETER url
|
|
Parameter description
|
|
|
|
.PARAMETER apiKey
|
|
Parameter description
|
|
|
|
.EXAMPLE
|
|
An example
|
|
|
|
.NOTES
|
|
General notes
|
|
#>
|
|
|
|
function New-Component() {
|
|
[CmdletBinding(
|
|
SupportsShouldProcess = $true,
|
|
ConfirmImpact = "Low"
|
|
)]
|
|
|
|
Param(
|
|
[parameter(mandatory = $true)]
|
|
[string]$name,
|
|
|
|
[parameter(mandatory = $true)]
|
|
[int]$category_id,
|
|
|
|
[parameter(mandatory = $true)]
|
|
[string]$qty,
|
|
|
|
[int]$company_id,
|
|
|
|
[int]$location_id,
|
|
|
|
[datetime]$purchase_date,
|
|
|
|
[float]$purchase_cost,
|
|
|
|
[parameter(mandatory = $true)]
|
|
[string]$url,
|
|
|
|
[parameter(mandatory = $true)]
|
|
[string]$apiKey
|
|
)
|
|
|
|
$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/components"
|
|
Method = 'POST'
|
|
Body = $Body
|
|
Token = $apiKey
|
|
}
|
|
|
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
|
$result = Invoke-SnipeitMethod @Parameters
|
|
}
|
|
|
|
$result
|
|
}
|
|
|