From 989af1bf88ce846c114eaf23b7f7463bbef7a179 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Fri, 9 Jul 2021 21:17:25 +0300 Subject: [PATCH 1/2] corrected typo --- SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 b/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 index b9c109b..9605d9b 100644 --- a/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 +++ b/SnipeitPS/Public/Remove-SnipeitManufacturer.ps1 @@ -39,7 +39,7 @@ function Remove-SnipeitManufacturer () process { foreach($manufacturer_id in $id){ $Parameters = @{ - Uri = "$url/api/v1/manufacturers/$manufacturer_id_id" + Uri = "$url/api/v1/manufacturers/$manufacturer_id" Method = 'Delete' Token = $apiKey } From bab98270fae88992c4dd97282065f66956af0395 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Fri, 9 Jul 2021 21:18:51 +0300 Subject: [PATCH 2/2] Added Set-SnipeitManufacturer --- SnipeitPS/Public/Set-SnipeitManufacturer.ps1 | 78 ++++++++++++++++++++ SnipeitPS/SnipeitPS.psd1 | 1 + 2 files changed, 79 insertions(+) create mode 100644 SnipeitPS/Public/Set-SnipeitManufacturer.ps1 diff --git a/SnipeitPS/Public/Set-SnipeitManufacturer.ps1 b/SnipeitPS/Public/Set-SnipeitManufacturer.ps1 new file mode 100644 index 0000000..d0c1064 --- /dev/null +++ b/SnipeitPS/Public/Set-SnipeitManufacturer.ps1 @@ -0,0 +1,78 @@ +<# + .SYNOPSIS + Add a new Manufacturer to Snipe-it asset system + + .DESCRIPTION + Long description + + .PARAMETER Name + Name of the Manufacturer + + .PARAMETER image + Image file name and path for item + + .PARAMETER image_delete + Remove current image + + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + + .PARAMETER url + URL of Snipeit system, can be set using Set-SnipeitInfo command + + .PARAMETER apiKey + Users API Key for Snipeit, can be set using Set-SnipeitInfo command + + .EXAMPLE + New-SnipeitManufacturer -name "HP" +#> + +function Set-SnipeitManufacturer() +{ + [CmdletBinding( + SupportsShouldProcess = $true, + ConfirmImpact = "Low" + )] + + Param( + [parameter(mandatory = $true)] + [string]$Name, + + [ValidateScript({Test-Path $_})] + [string]$image, + + [switch]$image_delete=$false, + + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + + [parameter(mandatory = $true)] + [string]$url, + + [parameter(mandatory = $true)] + [string]$apiKey + ) + + begin{ + Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name + + $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + } + + process{ + foreach ($manufacturer_id in $id) { + $Parameters = @{ + Uri = "$url/api/v1/manufacturers/$manufacturer_id" + Method = $RequestType + Body = $Values + Token = $apiKey + } + + If ($PSCmdlet.ShouldProcess("ShouldProcess?")) { + $result = Invoke-SnipeitMethod @Parameters + } + + $result + } + } +} diff --git a/SnipeitPS/SnipeitPS.psd1 b/SnipeitPS/SnipeitPS.psd1 index dbbb9ef..fb5fd68 100644 --- a/SnipeitPS/SnipeitPS.psd1 +++ b/SnipeitPS/SnipeitPS.psd1 @@ -135,6 +135,7 @@ FunctionsToExport = @( 'Set-SnipeitLicense', 'Set-SnipeitLicenseSeat', 'Set-SnipeitLocation', + 'Set-SnipeitManufacturer', 'Set-SnipeitModel', 'Set-SnipeitStatus', 'Set-SnipeitUser',