SnipeitPS/SnipeitPS/Public/New-Component.ps1
Petri Asikainen 6828244dfa #67
2021-01-29 18:08:19 +02:00

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
}