From ba1fdef8e508b5f6b2c24497e03a350797f9d64e Mon Sep 17 00:00:00 2001 From: erikjunker <57944222+erikjunker@users.noreply.github.com> Date: Thu, 6 Oct 2022 19:03:20 +0200 Subject: [PATCH 1/8] Update New-SnipeitAsset.md --- docs/New-SnipeitAsset.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/New-SnipeitAsset.md b/docs/New-SnipeitAsset.md index 02d563d..9b2d05d 100644 --- a/docs/New-SnipeitAsset.md +++ b/docs/New-SnipeitAsset.md @@ -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. ``` From f99ea3d8af6cf5ce56725f5edd30815f992e3718 Mon Sep 17 00:00:00 2001 From: erikjunker <57944222+erikjunker@users.noreply.github.com> Date: Thu, 6 Oct 2022 19:03:42 +0200 Subject: [PATCH 2/8] Update Set-SnipeitAsset.md --- docs/Set-SnipeitAsset.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Set-SnipeitAsset.md b/docs/Set-SnipeitAsset.md index 7952df5..0770fc0 100644 --- a/docs/Set-SnipeitAsset.md +++ b/docs/Set-SnipeitAsset.md @@ -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 From d64978fd6ffd2e18440f07aef68cc47fdefd021f Mon Sep 17 00:00:00 2001 From: JoriPS1 Date: Fri, 16 Sep 2022 11:59:32 -0400 Subject: [PATCH 3/8] Added: -purchase_order --- SnipeitPS/Public/New-SnipeitLicense.ps1 | 5 +++++ SnipeitPS/Public/Set-SnipeitLicense.ps1 | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/SnipeitPS/Public/New-SnipeitLicense.ps1 b/SnipeitPS/Public/New-SnipeitLicense.ps1 index 74ea39a..3e28dfe 100644 --- a/SnipeitPS/Public/New-SnipeitLicense.ps1 +++ b/SnipeitPS/Public/New-SnipeitLicense.ps1 @@ -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? @@ -108,6 +111,8 @@ function New-SnipeitLicense() { [datetime]$purchase_date, + [string]$purchase_order, + [bool]$reassignable, [string]$serial, diff --git a/SnipeitPS/Public/Set-SnipeitLicense.ps1 b/SnipeitPS/Public/Set-SnipeitLicense.ps1 index 21bfa9f..2f37522 100644 --- a/SnipeitPS/Public/Set-SnipeitLicense.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLicense.ps1 @@ -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, From b23f73737a96fff49736b4be49cc8d58bc360202 Mon Sep 17 00:00:00 2001 From: JoriPS1 Date: Fri, 16 Sep 2022 12:00:52 -0400 Subject: [PATCH 4/8] Removed: [ValidateLength()] from -license_email --- SnipeitPS/Public/New-SnipeitLicense.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/SnipeitPS/Public/New-SnipeitLicense.ps1 b/SnipeitPS/Public/New-SnipeitLicense.ps1 index 3e28dfe..3ad922d 100644 --- a/SnipeitPS/Public/New-SnipeitLicense.ps1 +++ b/SnipeitPS/Public/New-SnipeitLicense.ps1 @@ -92,7 +92,6 @@ function New-SnipeitLicense() { [datetime]$expiration_date, - [ValidateLength(1, 120)] [mailaddress]$license_email, [ValidateLength(1, 100)] From cc664e851ecd21af7eb8980e631def80dd5e52fb Mon Sep 17 00:00:00 2001 From: JoriPS1 Date: Fri, 16 Sep 2022 12:06:19 -0400 Subject: [PATCH 5/8] Fixed: -license_email must be string. --- SnipeitPS/Public/New-SnipeitLicense.ps1 | 4 ++++ SnipeitPS/Public/Set-SnipeitLicense.ps1 | 3 +++ 2 files changed, 7 insertions(+) diff --git a/SnipeitPS/Public/New-SnipeitLicense.ps1 b/SnipeitPS/Public/New-SnipeitLicense.ps1 index 3ad922d..f777df3 100644 --- a/SnipeitPS/Public/New-SnipeitLicense.ps1 +++ b/SnipeitPS/Public/New-SnipeitLicense.ps1 @@ -144,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' diff --git a/SnipeitPS/Public/Set-SnipeitLicense.ps1 b/SnipeitPS/Public/Set-SnipeitLicense.ps1 index 2f37522..9d9e322 100644 --- a/SnipeitPS/Public/Set-SnipeitLicense.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLicense.ps1 @@ -156,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 { From 016dde001df744564e60bc0be4ea2e29cf35c9f3 Mon Sep 17 00:00:00 2001 From: JoriPS1 Date: Fri, 16 Sep 2022 12:07:23 -0400 Subject: [PATCH 6/8] Fixed: Typo --- SnipeitPS/Public/New-SnipeitSupplier.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SnipeitPS/Public/New-SnipeitSupplier.ps1 b/SnipeitPS/Public/New-SnipeitSupplier.ps1 index 599dbe0..3038381 100644 --- a/SnipeitPS/Public/New-SnipeitSupplier.ps1 +++ b/SnipeitPS/Public/New-SnipeitSupplier.ps1 @@ -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 } From a016c4eb542aabd4bd8368684e7126b453b2b560 Mon Sep 17 00:00:00 2001 From: Frank Geisler Date: Fri, 18 Aug 2023 08:05:21 +0200 Subject: [PATCH 7/8] Corrected some typos in description, added password to mandatory, test if password is less than 8 chars --- SnipeitPS/Public/New-SnipeitUser.ps1 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/SnipeitPS/Public/New-SnipeitUser.ps1 b/SnipeitPS/Public/New-SnipeitUser.ps1 index 30f42dd..1a7776a 100644 --- a/SnipeitPS/Public/New-SnipeitUser.ps1 +++ b/SnipeitPS/Public/New-SnipeitUser.ps1 @@ -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 From 865a07d4ad37058549765c50f8d30b17a5b70992 Mon Sep 17 00:00:00 2001 From: Frank Geisler Date: Fri, 18 Aug 2023 08:19:20 +0200 Subject: [PATCH 8/8] Added Cmdlet New-SnipeItCustomFieldset --- .../Public/New-SnipeitCustomFieldset.ps1 | 73 +++++++++++++++++++ SnipeitPS/SnipeitPS.psd1 | 1 + 2 files changed, 74 insertions(+) create mode 100644 SnipeitPS/Public/New-SnipeitCustomFieldset.ps1 diff --git a/SnipeitPS/Public/New-SnipeitCustomFieldset.ps1 b/SnipeitPS/Public/New-SnipeitCustomFieldset.ps1 new file mode 100644 index 0000000..625da07 --- /dev/null +++ b/SnipeitPS/Public/New-SnipeitCustomFieldset.ps1 @@ -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 + } + } +} + diff --git a/SnipeitPS/SnipeitPS.psd1 b/SnipeitPS/SnipeitPS.psd1 index c742924..fb78e75 100644 --- a/SnipeitPS/SnipeitPS.psd1 +++ b/SnipeitPS/SnipeitPS.psd1 @@ -100,6 +100,7 @@ FunctionsToExport = @( 'New-SnipeitComponent', 'New-SnipeitConsumable', 'New-SnipeitCustomField', + 'New-SnipeitCustomFieldSet', 'New-SnipeitDepartment', 'New-SnipeitLicense', 'New-SnipeitLocation',