SnipeitPS/SnipeitPS/Public/Remove-SnipeitAsset.ps1

57 lines
1.4 KiB
PowerShell
Raw Normal View History

2020-01-23 11:08:42 -05:00
<#
.SYNOPSIS
Removes Asset from Snipe-it asset system
2020-01-23 11:08:42 -05:00
.DESCRIPTION
2021-06-12 12:30:41 +03:00
Removes asset or multiple assets from Snipe-it asset system
2020-01-23 11:08:42 -05:00
.PARAMETER ID
Unique ID For Asset to be removed
2021-05-19 15:51:49 +03:00
.PARAMETER url
2021-06-08 20:23:32 +03:00
URL of Snipeit system, can be set using Set-SnipeitInfo command
2021-05-19 15:51:49 +03:00
.PARAMETER apiKey
2021-06-08 20:23:32 +03:00
User's API Key for Snipeit, can be set using Set-SnipeitInfo command
2021-05-19 15:51:49 +03:00
2020-01-23 11:08:42 -05:00
.EXAMPLE
2021-06-08 20:23:32 +03:00
Remove-SnipeitAsset -ID 44 -Verbose
2021-06-12 12:30:41 +03:00
.EXAMPLE
Get-SnipeitAsset -serial 123456789 | Remove-SnipeitAsset
2020-01-23 11:08:42 -05:00
#>
2021-06-08 20:23:32 +03:00
function Remove-SnipeitAsset ()
2020-01-23 11:08:42 -05:00
{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "Low"
)]
Param(
2021-06-12 12:30:41 +03:00
[parameter(mandatory = $true,ValueFromPipelineByPropertyName)]
[int[]]$id,
2020-01-23 11:08:42 -05:00
[parameter(mandatory = $true)]
[string]$URL,
[parameter(mandatory = $true)]
[string]$APIKey
)
2021-06-12 12:30:41 +03:00
begin {
Test-SnipeitAlias -invocationName $MyInvocation.InvocationName -commandName $MyInvocation.MyCommand.Name
2020-01-23 11:08:42 -05:00
}
2021-06-12 12:30:41 +03:00
process {
foreach($asset_id in $id){
$Parameters = @{
Uri = "$url/api/v1/hardware/$asset_id"
Method = 'Delete'
Body = '@{}'
2021-06-12 12:30:41 +03:00
Token = $apiKey
}
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
{
$result = Invoke-SnipeitMethod @Parameters
}
$result
}
2020-01-23 11:08:42 -05:00
}
}