mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-15 02:35:47 +00:00
Added Cmdlet New-SnipeItCustomFieldset
This commit is contained in:
parent
a016c4eb54
commit
865a07d4ad
2 changed files with 74 additions and 0 deletions
73
SnipeitPS/Public/New-SnipeitCustomFieldset.ps1
Normal file
73
SnipeitPS/Public/New-SnipeitCustomFieldset.ps1
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Add a new Custom Fieldset to Snipe-it asset system
|
||||
|
||||
.DESCRIPTION
|
||||
Add a new Custom Field Set to Snipe-it asset system
|
||||
|
||||
.PARAMETER name
|
||||
The fieldsets's name
|
||||
|
||||
.PARAMETER url
|
||||
Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system.
|
||||
|
||||
.PARAMETER apiKey
|
||||
Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key for Snipeit.
|
||||
|
||||
.EXAMPLE
|
||||
New-SnipeitCustomFieldSet -Name "Notebook Fields"
|
||||
#>
|
||||
|
||||
function New-SnipeitCustomFieldSet() {
|
||||
[CmdletBinding(
|
||||
SupportsShouldProcess = $true,
|
||||
ConfirmImpact = "Low"
|
||||
)]
|
||||
|
||||
Param(
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$name,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory = $false)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
begin {
|
||||
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
|
||||
|
||||
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
|
||||
|
||||
$Parameters = @{
|
||||
Api = "/api/v1/fieldsets"
|
||||
Method = 'post'
|
||||
Body = $Values
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
|
||||
Set-SnipeitPSLegacyApiKey -apiKey $apikey
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url) {
|
||||
Set-SnipeitPSLegacyUrl -url $url
|
||||
}
|
||||
}
|
||||
|
||||
process{
|
||||
if ($PSCmdlet.ShouldProcess("ShouldProcess?")) {
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
end {
|
||||
# reset legacy sessions
|
||||
if ($PSBoundParameters.ContainsKey('url') -and '' -ne [string]$url -or $PSBoundParameters.ContainsKey('apiKey') -and '' -ne [string]$apiKey) {
|
||||
Reset-SnipeitPSLegacyApi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,6 +100,7 @@ FunctionsToExport = @(
|
|||
'New-SnipeitComponent',
|
||||
'New-SnipeitConsumable',
|
||||
'New-SnipeitCustomField',
|
||||
'New-SnipeitCustomFieldSet',
|
||||
'New-SnipeitDepartment',
|
||||
'New-SnipeitLicense',
|
||||
'New-SnipeitLocation',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue