Public/Set-SnipeitCompany.ps1
<# .SYNOPSIS Updates company name .DESCRIPTION Updates companyt name on Snipe-It system .PARAMETER id ID number of company .PARAMETER name Company name .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 Deprecated parameter, please use Connect-SnipeitPS instead. URL of Snipeit system. .PARAMETER apiKey Deprecated parameter, please use Connect-SnipeitPS instead. Users API Key API Key for Snipeit. .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, [ValidateScript({Test-Path $_})] [string]$image, [switch]$image_delete=$false, [ValidateSet("Put","Patch")] [string]$RequestType = "Patch", [parameter(mandatory = $false)] [string]$url, [parameter(mandatory = $false)] [string]$apiKey ) begin{ $Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters } process{ foreach($company_id in $id) { $Parameters = @{ Api = "/api/v1/companies/$company_id" Method = $RequestType Body = $Values } if ($PSBoundParameters.ContainsKey('apiKey')) { Write-Warning "-apiKey parameter is deprecated, please use Connect-SnipeitPS instead." Set-SnipeitPSLegacyApiKey -apiKey $apikey } if ($PSBoundParameters.ContainsKey('url')) { Write-Warning "-url parameter is deprecated, please use Connect-SnipeitPS instead." Set-SnipeitPSLegacyUrl -url $url } if ($PSCmdlet.ShouldProcess("ShouldProcess?")) { $result = Invoke-SnipeitMethod @Parameters } $result } } end { # reset legacy sessions if ($PSBoundParameters.ContainsKey('url') -or $PSBoundParameters.ContainsKey('apiKey')) { Reset-SnipeitPSLegacyApi } } } |