Public/Remove-DuneRole.ps1
|
<# .SYNOPSIS Remove a role. .DESCRIPTION Deletes a role by sending a DELETE request. Accepts a role object via pipeline or by id. ShouldProcess is observed. .PARAMETER Role A `DuneRole` object to remove (pipeline input supported). .PARAMETER Id The GUID of the role to remove. .EXAMPLE PS> Get-DuneRole -Name "Auditor" -AppliesTo Deployment | Remove-DuneRole Removes the Auditor role for deployments. .EXAMPLE PS> Remove-DuneRole -Id $RoleId Removes the role with the specified id. #> function Remove-DuneRole { [CmdletBinding( SupportsShouldProcess, DefaultParameterSetName = 'Id', ConfirmImpact = 'High' )] param( [Parameter(ValueFromPipeline, ParameterSetName = 'Object')] [DuneRole]$Role, [Parameter(ParameterSetName = 'Id')] [guid]$Id ) begin {} process { Write-Debug "$($MyInvocation.MyCommand)|process|$($PSCmdlet.ParameterSetName)" if ($PSCmdlet.ParameterSetName -eq 'Id') { $Role = Get-DuneRole -Id $Id -ErrorAction Stop } if ($PSCmdlet.ShouldProcess($Role.Name)) { $null = Invoke-DuneApiRequest -Uri "authorization/roles/$($Role.Id)" -Method DELETE -ErrorAction Stop } } end {} } |