From b19aa28e410902526282f121d06d6549cbd6e2b6 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Tue, 15 Jun 2021 14:09:59 +0300 Subject: [PATCH 1/9] build with powershell 5 and 7 --- SnipeitPS.build.ps1 | 17 ++++++++--------- SnipeitPS/SnipeitPS.psd1 | 2 +- appveyor.yml | 39 ++++++++++++++++++++++++++++++++++----- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/SnipeitPS.build.ps1 b/SnipeitPS.build.ps1 index 03a623d..48a0ac9 100644 --- a/SnipeitPS.build.ps1 +++ b/SnipeitPS.build.ps1 @@ -88,15 +88,14 @@ task GitStatus -If (Test-Path .git) { } } -task TestVersions TestPS3, TestPS4, TestPS4, TestPS5 -task TestPS3 { - exec {powershell.exe -Version 3 -NoProfile Invoke-Build PesterTests} -} -task TestPS4 { - exec {powershell.exe -Version 4 -NoProfile Invoke-Build PesterTests} -} -task TestPS5 { - exec {powershell.exe -Version 5 -NoProfile Invoke-Build PesterTests} +task TestVersions TestPS + +task TestPS { + if($env:PShell -eq '7') { + exec {pwsh.exe -NoProfile Invoke-Build PesterTests} + }else { + exec {powershell.exe -NoProfile Invoke-Build PesterTests} + } } # Synopsis: Invoke Pester Tests diff --git a/SnipeitPS/SnipeitPS.psd1 b/SnipeitPS/SnipeitPS.psd1 index 9b5b712..f5c1113 100644 --- a/SnipeitPS/SnipeitPS.psd1 +++ b/SnipeitPS/SnipeitPS.psd1 @@ -33,7 +33,7 @@ Copyright = '(c) 2017 Stephen Maunder. All rights reserved.' Description = 'Powershell API for Snipeit Asset Management' # Minimum version of the Windows PowerShell engine required by this module -PowerShellVersion = '3.0' +PowerShellVersion = '5.1' # Name of the Windows PowerShell host required by this module # PowerShellHostName = '' diff --git a/appveyor.yml b/appveyor.yml index 228ef4f..3d616c3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,12 +7,15 @@ # ############################################################ -# This tells AppVeyor that we need WMF 5 and PowerShell 5.0 -os: WMF 5 +# powershell core and 5.1 +image: + - Visual Studio 2017 + - Visual Studio 2019 environment: PSGalleryAPIKey: secure: UdM6qhf5B0G8liHhUrwWERCZr44iSqmg4jUq0lwlTjZs4KyeoiwnBzdej0phqIAm + PShell: '5' version: 1.7.{build} @@ -53,15 +56,41 @@ before_build: build_script: - ps: Invoke-Build -Task Build -# after_build: - # - cmd: mdspell %releasePath%\**/*.md --ignore-numbers --ignore-acronyms --report - test_script: - ps: Invoke-Build -Task Test before_deploy: - ps: Invoke-Build -Task Deploy +#Build with powershell core +for: + - + matrix: + only: + - image: Visual Studio 2019 + environment: + - PShell: '7' + install: + - pwsh: | + Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null + Install-Module InvokeBuild -Scope CurrentUser -Force + Install-Module BuildHelpers -Scope CurrentUser -Force + Install-Module platyPS -Scope CurrentUser -Force + Install-Module Pester -Scope CurrentUser -Force + Install-Module PSScriptAnalyzer -Scope CurrentUser -Force + $env:releasePath = "$($pwd.Path)\Release" + before_build: + - pwsh: Invoke-Build -Task ShowDebug + build_script: + - pwsh: Invoke-Build -Task Build + + test_script: + - pwsh: Invoke-Build -Task Test + + before_deploy: + - pwsh: Invoke-Build -Task Deploy + + deploy: provider: GitHub release: v$(appveyor_build_version) From fad878460a5e7069e28480064bc507457160f707 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Tue, 15 Jun 2021 14:16:12 +0300 Subject: [PATCH 2/9] build with powershell 5 and 7 --- SnipeitPS.build.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SnipeitPS.build.ps1 b/SnipeitPS.build.ps1 index 48a0ac9..12627d7 100644 --- a/SnipeitPS.build.ps1 +++ b/SnipeitPS.build.ps1 @@ -191,7 +191,9 @@ task Deploy -If ( (-not ($env:APPVEYOR_PULL_REQUEST_NUMBER)) -and # Do not deploy if the commit contains the string "skip-deploy" # Meant for major/minor version publishes with a .0 build/patch version (like 2.1.0) - $env:APPVEYOR_REPO_COMMIT_MESSAGE -notlike '*skip-deploy*' + $env:APPVEYOR_REPO_COMMIT_MESSAGE -notlike '*skip-deploy*' -and + # publish from one powershell version is enought + $env:PShell -eq '5' ) { Remove-Module SnipeitPS -ErrorAction SilentlyContinue }, PublishToGallery From cbc80dc633ece64a09e36749e51049134b3f19b5 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Tue, 15 Jun 2021 14:23:48 +0300 Subject: [PATCH 3/9] corrected indentation --- appveyor.yml | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 3d616c3..1529ff1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -68,27 +68,27 @@ for: matrix: only: - image: Visual Studio 2019 - environment: - - PShell: '7' - install: - - pwsh: | - Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null - Install-Module InvokeBuild -Scope CurrentUser -Force - Install-Module BuildHelpers -Scope CurrentUser -Force - Install-Module platyPS -Scope CurrentUser -Force - Install-Module Pester -Scope CurrentUser -Force - Install-Module PSScriptAnalyzer -Scope CurrentUser -Force - $env:releasePath = "$($pwd.Path)\Release" - before_build: - - pwsh: Invoke-Build -Task ShowDebug - build_script: - - pwsh: Invoke-Build -Task Build + environment: + - PShell: '7' + install: + - pwsh: | + Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null + Install-Module InvokeBuild -Scope CurrentUser -Force + Install-Module BuildHelpers -Scope CurrentUser -Force + Install-Module platyPS -Scope CurrentUser -Force + Install-Module Pester -Scope CurrentUser -Force + Install-Module PSScriptAnalyzer -Scope CurrentUser -Force + $env:releasePath = "$($pwd.Path)\Release" + before_build: + - pwsh: Invoke-Build -Task ShowDebug + build_script: + - pwsh: Invoke-Build -Task Build - test_script: - - pwsh: Invoke-Build -Task Test + test_script: + - pwsh: Invoke-Build -Task Test - before_deploy: - - pwsh: Invoke-Build -Task Deploy + before_deploy: + - pwsh: Invoke-Build -Task Deploy deploy: From eb3b334e42370920bea8261bbc5dda248156e3ef Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Tue, 15 Jun 2021 14:25:03 +0300 Subject: [PATCH 4/9] corrected indentation --- appveyor.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 1529ff1..2f6b8e4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -72,13 +72,13 @@ for: - PShell: '7' install: - pwsh: | - Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null - Install-Module InvokeBuild -Scope CurrentUser -Force - Install-Module BuildHelpers -Scope CurrentUser -Force - Install-Module platyPS -Scope CurrentUser -Force - Install-Module Pester -Scope CurrentUser -Force - Install-Module PSScriptAnalyzer -Scope CurrentUser -Force - $env:releasePath = "$($pwd.Path)\Release" + Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null + Install-Module InvokeBuild -Scope CurrentUser -Force + Install-Module BuildHelpers -Scope CurrentUser -Force + Install-Module platyPS -Scope CurrentUser -Force + Install-Module Pester -Scope CurrentUser -Force + Install-Module PSScriptAnalyzer -Scope CurrentUser -Force + $env:releasePath = "$($pwd.Path)\Release" before_build: - pwsh: Invoke-Build -Task ShowDebug build_script: From da7dd14c4b9f3eed809ef5a2778b8e43e01c80e8 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Tue, 15 Jun 2021 14:27:04 +0300 Subject: [PATCH 5/9] matrix settings --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 2f6b8e4..f285fda 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -69,7 +69,7 @@ for: only: - image: Visual Studio 2019 environment: - - PShell: '7' + PShell: '7' install: - pwsh: | Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null From c485fcd23063519996e4e60648771f487483d56c Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Tue, 15 Jun 2021 14:33:02 +0300 Subject: [PATCH 6/9] corrected indentation --- appveyor.yml | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f285fda..74cc040 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -68,27 +68,27 @@ for: matrix: only: - image: Visual Studio 2019 - environment: - PShell: '7' - install: - - pwsh: | - Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null - Install-Module InvokeBuild -Scope CurrentUser -Force - Install-Module BuildHelpers -Scope CurrentUser -Force - Install-Module platyPS -Scope CurrentUser -Force - Install-Module Pester -Scope CurrentUser -Force - Install-Module PSScriptAnalyzer -Scope CurrentUser -Force - $env:releasePath = "$($pwd.Path)\Release" - before_build: - - pwsh: Invoke-Build -Task ShowDebug - build_script: - - pwsh: Invoke-Build -Task Build + environment: + PShell: '7' + install: + - pwsh: | + Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null + Install-Module InvokeBuild -Scope CurrentUser -Force + Install-Module BuildHelpers -Scope CurrentUser -Force + Install-Module platyPS -Scope CurrentUser -Force + Install-Module Pester -Scope CurrentUser -Force + Install-Module PSScriptAnalyzer -Scope CurrentUser -Force + $env:releasePath = "$($pwd.Path)\Release" + before_build: + - pwsh: Invoke-Build -Task ShowDebug + build_script: + - pwsh: Invoke-Build -Task Build - test_script: - - pwsh: Invoke-Build -Task Test + test_script: + - pwsh: Invoke-Build -Task Test - before_deploy: - - pwsh: Invoke-Build -Task Deploy + before_deploy: + - pwsh: Invoke-Build -Task Deploy deploy: From aaeab1cb272e81753fccd5dc2c04bd8c0f5f29c9 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Tue, 15 Jun 2021 14:36:03 +0300 Subject: [PATCH 7/9] pwsh already have nuget --- appveyor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 74cc040..0fb5249 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -72,7 +72,6 @@ for: PShell: '7' install: - pwsh: | - Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null Install-Module InvokeBuild -Scope CurrentUser -Force Install-Module BuildHelpers -Scope CurrentUser -Force Install-Module platyPS -Scope CurrentUser -Force From 36a9fe3d04e39a03408755f1b38377afe9eb2ad0 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Wed, 16 Jun 2021 00:55:08 +0300 Subject: [PATCH 8/9] use nullable ints --- SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 b/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 index 78f9525..9dedbae 100644 --- a/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 @@ -46,9 +46,9 @@ function Set-SnipeitLicenseSeat() [int]$seat_id, [Alias('assigned_id')] - [int]$assigned_to, + [Nullable[System.Int32]]$assigned_to, - [int]$asset_id, + [Nullable[System.Int32]]$asset_id, [string]$note, From 14ae8c19220c2bc1d10c2578197fb6009532487a Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Wed, 16 Jun 2021 01:04:35 +0300 Subject: [PATCH 9/9] added min_amt parameter --- SnipeitPS/Public/Set-SnipeitComponent.ps1 | 5 +++ docs/Set-SnipeitComponent.md | 41 ++++++++++++++++------- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/SnipeitPS/Public/Set-SnipeitComponent.ps1 b/SnipeitPS/Public/Set-SnipeitComponent.ps1 index 97115d9..cc6363a 100644 --- a/SnipeitPS/Public/Set-SnipeitComponent.ps1 +++ b/SnipeitPS/Public/Set-SnipeitComponent.ps1 @@ -17,6 +17,9 @@ ID number of category .PARAMETER qty Quantity of the components you have +.PARAMETER min_amt +Minimum Quantity of the components before alert is triggered + .PARAMETER location_id ID number of the location the accessory is assigned to @@ -55,6 +58,8 @@ function Set-SnipeitComponent() [parameter(mandatory = $true)] [int]$qty, + [int]$min_amt, + [string]$name, [int]$company_id, diff --git a/docs/Set-SnipeitComponent.md b/docs/Set-SnipeitComponent.md index cbf0d06..aff4e3b 100644 --- a/docs/Set-SnipeitComponent.md +++ b/docs/Set-SnipeitComponent.md @@ -13,9 +13,9 @@ Updates component ## SYNTAX ``` -Set-SnipeitComponent [-id] [-qty] [[-name] ] [[-company_id] ] - [[-location_id] ] [[-order_number] ] [[-purchase_date] ] [[-purchase_cost] ] - [-url] [-apiKey] [-WhatIf] [-Confirm] [] +Set-SnipeitComponent [-id] [-qty] [[-min_amt] ] [[-name] ] + [[-company_id] ] [[-location_id] ] [[-order_number] ] [[-purchase_date] ] + [[-purchase_cost] ] [-url] [-apiKey] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -39,7 +39,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 10 +Position: 11 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -54,7 +54,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 4 +Position: 5 Default value: 0 Accept pipeline input: False Accept wildcard characters: False @@ -64,14 +64,14 @@ Accept wildcard characters: False ID number of name ```yaml -Type: Int32 +Type: Int32[] Parameter Sets: (All) Aliases: Required: True Position: 1 Default value: 0 -Accept pipeline input: False +Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` @@ -84,7 +84,22 @@ Parameter Sets: (All) Aliases: Required: False -Position: 5 +Position: 6 +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -min_amt +Minimum Quantity of the components before alert is triggered + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 Default value: 0 Accept pipeline input: False Accept wildcard characters: False @@ -99,7 +114,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 3 +Position: 4 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -114,7 +129,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 6 +Position: 7 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -129,7 +144,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 8 +Position: 9 Default value: 0 Accept pipeline input: False Accept wildcard characters: False @@ -144,7 +159,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 7 +Position: 8 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -174,7 +189,7 @@ Parameter Sets: (All) Aliases: Required: True -Position: 9 +Position: 10 Default value: None Accept pipeline input: False Accept wildcard characters: False