SnipeitPS/SnipeitPS/Public/Set-SnipeitAccessoryOwner.ps1
2021-06-08 20:23:32 +03:00

70 lines
1.6 KiB
PowerShell

<#
.SYNOPSIS
Checkout accessory
.DESCRIPTION
Checkout accessory to user
.PARAMETER id
Unique ID For accessory or array of IDs to checkout
.PARAMETER assigned_id
Id of target user
.PARAMETER note
Notes about checkout
.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
Set-SnipeitAccessoryOwner -id 1 -assigned_id 1 -note "testing check out to user"
#>
function Set-SnipeitAccessoryOwner()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Medium"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $true)]
[int]$assigned_to,
[string] $note,
[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($accessory_id in $id){
$Parameters = @{
Uri = "$url/api/v1/accessories/$accessory_id/checkout"
Method = 'POST'
Body = $Body
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
return $result
}
}
}