2017-11-20 09:07:58 +00:00
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
|
|
|
|
Add a new Model to Snipe-it asset system
|
|
|
|
|
|
|
|
|
|
.DESCRIPTION
|
|
|
|
|
Long description
|
|
|
|
|
|
|
|
|
|
.PARAMETER name
|
|
|
|
|
Name of the Asset Model
|
|
|
|
|
|
2021-05-19 15:51:49 +03:00
|
|
|
.PARAMETER model_number
|
|
|
|
|
Model number of the Asset Model
|
|
|
|
|
|
2017-11-20 09:07:58 +00:00
|
|
|
.PARAMETER category_id
|
|
|
|
|
Category ID that the asset belongs to this can be got using Get-Category
|
|
|
|
|
|
|
|
|
|
.PARAMETER manufacturer_id
|
|
|
|
|
Manufacturer ID that the asset belongs to this can be got using Get-Manufacturer
|
|
|
|
|
|
|
|
|
|
.PARAMETER fieldset_id
|
|
|
|
|
Fieldset ID that the asset uses (Custom fields)
|
|
|
|
|
|
|
|
|
|
.PARAMETER url
|
2021-05-22 18:44:36 +03:00
|
|
|
URL of Snipeit system, can be set using Set-SnipeItInfo command
|
2017-11-20 09:07:58 +00:00
|
|
|
|
|
|
|
|
.PARAMETER apiKey
|
2021-05-22 18:44:36 +03:00
|
|
|
Users API Key for Snipeit, can be set using Set-SnipeItInfo command
|
2017-11-20 09:07:58 +00:00
|
|
|
|
|
|
|
|
.EXAMPLE
|
2021-05-23 23:22:23 +03:00
|
|
|
New-SnipeItModel -name "DL380" -manufacturer_id 2 -fieldset_id 2 -category_id 1
|
2017-11-20 09:07:58 +00:00
|
|
|
#>
|
|
|
|
|
|
2021-05-22 18:44:36 +03:00
|
|
|
function New-SnipeItModel()
|
2017-11-19 20:57:27 +00:00
|
|
|
{
|
|
|
|
|
[CmdletBinding(
|
|
|
|
|
SupportsShouldProcess = $true,
|
2018-01-22 08:32:04 +00:00
|
|
|
ConfirmImpact = "Low"
|
2017-11-19 20:57:27 +00:00
|
|
|
)]
|
|
|
|
|
|
|
|
|
|
Param(
|
|
|
|
|
[parameter(mandatory = $true)]
|
|
|
|
|
[string]$name,
|
|
|
|
|
|
2019-04-26 16:30:00 +01:00
|
|
|
[string]$model_number,
|
|
|
|
|
|
2017-11-19 20:57:27 +00:00
|
|
|
[parameter(mandatory = $true)]
|
|
|
|
|
[int]$category_id,
|
|
|
|
|
|
|
|
|
|
[parameter(mandatory = $true)]
|
|
|
|
|
[int]$manufacturer_id,
|
|
|
|
|
|
2019-04-26 16:30:00 +01:00
|
|
|
[int]$eol,
|
|
|
|
|
|
2017-11-19 20:57:27 +00:00
|
|
|
[parameter(mandatory = $true)]
|
|
|
|
|
[int]$fieldset_id,
|
|
|
|
|
|
|
|
|
|
[parameter(mandatory = $true)]
|
|
|
|
|
[string]$url,
|
|
|
|
|
|
|
|
|
|
[parameter(mandatory = $true)]
|
|
|
|
|
[string]$apiKey
|
|
|
|
|
)
|
|
|
|
|
|
2021-05-23 19:23:24 +03:00
|
|
|
Test-SnipeItAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
|
|
|
|
|
2017-11-19 20:57:27 +00:00
|
|
|
$Values = @{
|
|
|
|
|
name = $name
|
|
|
|
|
category_id = $category_id
|
|
|
|
|
manufacturer_id = $manufacturer_id
|
|
|
|
|
fieldset_id = $fieldset_id
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-26 16:30:00 +01:00
|
|
|
if ($PSBoundParameters.ContainsKey('model_number')) { $Values.Add("model_number", $model_number) }
|
|
|
|
|
if ($PSBoundParameters.ContainsKey('eol')) { $Values.Add("eol", $eol) }
|
|
|
|
|
|
2017-11-19 20:57:27 +00:00
|
|
|
$Body = $Values | ConvertTo-Json;
|
|
|
|
|
|
|
|
|
|
$Parameters = @{
|
|
|
|
|
Uri = "$url/api/v1/models"
|
|
|
|
|
Method = 'post'
|
|
|
|
|
Body = $Body
|
|
|
|
|
Token = $apiKey
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 09:12:54 +00:00
|
|
|
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
2017-11-19 20:57:27 +00:00
|
|
|
{
|
2017-12-28 14:17:22 +00:00
|
|
|
$result = Invoke-SnipeitMethod @Parameters
|
2017-11-19 20:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$result
|
|
|
|
|
}
|