Public/Remove-DuneActionAssignment.ps1
|
<#
.SYNOPSIS Remove an action-assignment from a target. .DESCRIPTION Deletes an action assignment by sending a DELETE request. Accepts an assignment object via pipeline or by ID. ShouldProcess is observed. .PARAMETER ActionAssignment A `DuneActionAssignment` object to remove. Accepts pipeline input. .PARAMETER ActionAssignmentId The GUID of the action assignment to remove. .EXAMPLE PS> Remove-DuneActionAssignment -ActionAssignmentId 3d8f6b5a-... Removes the action assignment by ID. .EXAMPLE PS> Get-DuneActionAssignment -Name "old" | Remove-DuneActionAssignment Removes assignments via pipeline. #> function Remove-DuneActionAssignment { [CmdletBinding( SupportsShouldProcess, DefaultParameterSetName = 'Id', ConfirmImpact = 'High' )] param( [Parameter(ParameterSetName = 'Object', ValueFromPipeline)] [DuneActionAssignment]$ActionAssignment, [Parameter(ParameterSetName = 'Id')] [guid]$ActionAssignmentId ) begin {} process { if ($PSCmdlet.ParameterSetName -eq 'Id') { $ActionAssignment = Get-DuneActionAssignment -Id $ActionAssignmentId } $Uri = 'action-assignments/{0}' -f $ActionAssignment.Id if ($PSCmdlet.ShouldProcess($ActionAssignment.Name)) { $Null = Invoke-DuneApiRequest -Uri $Uri -Method DELETE } } end {} } |