SnipeitPS/SnipeitPS/Public/Set-SnipeitCompany.ps1

80 lines
1.5 KiB
PowerShell
Raw Normal View History

2021-06-13 18:17:05 +03:00
<#
.SYNOPSIS
Updates company name
.DESCRIPTION
Updates companyt name on Snipe-It system
.PARAMETER id
ID number of company
.PARAMETER name
Company name
2021-07-08 23:59:31 +03:00
.PARAMETER image
Image file name and path for item
.PARAMETER image_delete
Remove current image
2021-06-13 18:17:05 +03:00
.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,
2021-07-08 23:59:31 +03:00
[ValidateScript({Test-Path $_})]
[string]$image,
[switch]$image_delete=$false,
2021-06-13 18:17:05 +03:00
[parameter(mandatory = $true)]
[string]$url,
[parameter(mandatory = $true)]
[string]$apiKey
)
begin{
$Values = . Get-ParameterValue -Parameters $MyInvocation.MyCommand.Parameters -BoundParameters $PSBoundParameters
2021-06-13 18:17:05 +03:00
}
process{
foreach($company_id in $id){
$Parameters = @{
2021-06-13 18:32:42 +03:00
Uri = "$url/api/v1/companies/$company_id"
2021-06-13 18:17:05 +03:00
Method = 'Patch'
Body = $Values
2021-06-13 18:17:05 +03:00
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
}