This commit is contained in:
Frank Geisler 2023-08-18 06:19:28 +00:00 committed by GitHub
commit c973eeb735
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 100 additions and 7 deletions

View 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
}
}
}

View file

@ -47,6 +47,9 @@
.PARAMETER purchase_date
Date of license purchase
.PARAMETER purchase_order
Purchase order number of license purchase
.PARAMETER reassignable
Is license reassignable?
@ -89,7 +92,6 @@ function New-SnipeitLicense() {
[datetime]$expiration_date,
[ValidateLength(1, 120)]
[mailaddress]$license_email,
[ValidateLength(1, 100)]
@ -108,6 +110,8 @@ function New-SnipeitLicense() {
[datetime]$purchase_date,
[string]$purchase_order,
[bool]$reassignable,
[string]$serial,
@ -140,6 +144,10 @@ function New-SnipeitLicense() {
$Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd")
}
if ($Values['license_email']) {
$Values['license_email'] = $Values['license_email'].address
}
$Parameters = @{
Api = "/api/v1/licenses"
Method = 'POST'

View file

@ -102,7 +102,7 @@ function New-SnipeitSupplier() {
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
$Parameters = @{
Api = "/api/v1/suppilers"
Api = "/api/v1/suppliers"
Method = 'POST'
Body = $Values
}

View file

@ -14,11 +14,11 @@
.PARAMETER username
Username for user
.PARAMETER active
.PARAMETER activated
Can user log in to snipe-it?
.PARAMETER password
Password for user
Password for user. The password should at least be 8 characters long.
.PARAMETER notes
User Notes
@ -63,7 +63,7 @@
Deprecated parameter, please use Connect-SnipeitPS instead. User's API Key for Snipeit.
.EXAMPLE
New-Snipeituser -fist_name It -lastname Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1
New-Snipeituser -first_name It -last_name Snipe -username snipeit -activated $false -company_id 1 -location_id 1 -department_id 1
Creates new a new user who can't login to system
.NOTES
@ -86,6 +86,8 @@ function New-SnipeitUser() {
[parameter(mandatory = $true)]
[string]$username,
[ValidateScript({$_.Length -ge 8}, ErrorMessage = "Password should be at least 8 characters.")]
[parameter(mandatory = $true)]
[string]$password,
[bool]$activated = $false,
@ -122,6 +124,7 @@ function New-SnipeitUser() {
[string]$apiKey
)
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters

View file

@ -50,6 +50,9 @@
.PARAMETER purchase_date
Date of license purchase
.PARAMETER purchase_order
Purchase order number of license purchase
.PARAMETER reassignable
Is license reassignable?
@ -116,6 +119,8 @@ function Set-SnipeitLicense() {
[datetime]$purchase_date,
[string]$purchase_order,
[bool]$reassignable,
[string]$serial,
@ -151,6 +156,9 @@ function Set-SnipeitLicense() {
$Values['termination_date'] = $Values['termination_date'].ToString("yyyy-MM-dd")
}
if ($Values['license_email']) {
$Values['license_email'] = $Values['license_email'].address
}
}
process {

View file

@ -100,6 +100,7 @@ FunctionsToExport = @(
'New-SnipeitComponent',
'New-SnipeitConsumable',
'New-SnipeitCustomField',
'New-SnipeitCustomFieldSet',
'New-SnipeitDepartment',
'New-SnipeitLicense',
'New-SnipeitLocation',

View file

@ -49,7 +49,7 @@ Specifying asset tag when creating asset
### EXAMPLE 3
```
New-SnipeitAsset -status_id 1 -model_id 1 -name "Machine1" -customfields = @{ "_snipeit_os_5" = "Windows 10 Pro" }
New-SnipeitAsset -status_id 1 -model_id 1 -name "Machine1" -customfields @{ "_snipeit_os_5" = "Windows 10 Pro" }
Using customfields when creating asset.
```

View file

@ -33,7 +33,7 @@ Set-SnipeitAsset -id 1 -status_id 1 -model_id 1 -name "Machine1"
### EXAMPLE 2
```
Set-SnipeitAsset -id 1 -name "Machine1" -customfields = @{ "_snipeit_os_5" = "Windows 10 Pro" ; "_snipeit_os_version" = "1909" }
Set-SnipeitAsset -id 1 -name "Machine1" -customfields @{ "_snipeit_os_5" = "Windows 10 Pro" ; "_snipeit_os_version" = "1909" }
```
### EXAMPLE 3