From 621ee767093104a77ffedc85080c58c497ba1bf6 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Sun, 13 Jun 2021 18:17:05 +0300 Subject: [PATCH] add set-snipeitcompany --- SnipeitPS/Public/Set-SnipeitCompany.ps1 | 70 +++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 SnipeitPS/Public/Set-SnipeitCompany.ps1 diff --git a/SnipeitPS/Public/Set-SnipeitCompany.ps1 b/SnipeitPS/Public/Set-SnipeitCompany.ps1 new file mode 100644 index 0000000..050e20c --- /dev/null +++ b/SnipeitPS/Public/Set-SnipeitCompany.ps1 @@ -0,0 +1,70 @@ +<# +.SYNOPSIS +Updates company name + +.DESCRIPTION +Updates companyt name on Snipe-It system + +.PARAMETER id +ID number of company + +.PARAMETER name +Company name + +.PARAMETER url +URL of Snipeit system, can be set using Set-SnipeitInfo command + +.PARAMETER apiKey +User's API Key for Snipeit, can be set using Set-SnipeitInfo command + +.EXAMPLE +An example + +.NOTES +General notes +#> +function Set-SnipeitCompany() +{ + [CmdletBinding( + SupportsShouldProcess = $true, + ConfirmImpact = "Medium" + )] + + Param( + [parameter(mandatory = $true,ValueFromPipelineByPropertyName)] + [int[]]$id, + + [parameter(mandatory = $true)] + [string]$name, + + [parameter(mandatory = $true)] + [string]$url, + + [parameter(mandatory = $true)] + [string]$apiKey + ) + + begin{ + $values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters + + $Body = $values | ConvertTo-Json; + } + + process{ + foreach($company_id in $id){ + $Parameters = @{ + Uri = "$url/api/v1/companies/$companyid" + Method = 'Patch' + Body = $Body + Token = $apiKey + } + + If ($PSCmdlet.ShouldProcess("ShouldProcess?")) + { + $result = Invoke-SnipeitMethod @Parameters + } + + $result + } + } +}