SnipeitPS/SnipeitPS/Public/Remove-SnipeitCategory.ps1
2021-06-12 12:30:41 +03:00

55 lines
1.3 KiB
PowerShell

<#
.SYNOPSIS
Removes category from Snipe-it asset system
.DESCRIPTION
Removes category or multiple categories from Snipe-it asset system
.PARAMETER ID
Unique ID For categoryto be removed
.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
Remove-SnipeitCategory -ID 44 -Verbose
.EXAMPLE
Get-SnipeitCategory -search something | Remove-SnipeitCategory
#>
function Remove-SnipeitModel ()
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
[parameter(mandatory = $true)]
[string]$URL,
[parameter(mandatory = $true)]
[string]$APIKey
)
begin {
}
process {
foreach($category_id in $id){
$Parameters = @{
Uri = "$url/api/v1/categories/$category_id"
Method = 'Delete'
Body = '{}'
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
}
}