Public/Requests/Deny-SCAAccessRequest.ps1
|
function Deny-SCAAccessRequest { <# .SYNOPSIS Rejects a pending access request. .DESCRIPTION Calls POST /workflows/requests/{requestId}/finalize on the Access Requests API with a rejection decision. The caller must hold the "Access request approver" role for the request to be visible and rejectable. .PARAMETER RequestId The access request to reject. .PARAMETER Reason An optional rejection comment. .PARAMETER Session A psSCA.Session object or session name. Defaults to the current default session. .EXAMPLE Deny-SCAAccessRequest -RequestId 'a1b2c3d4-request-id' -Reason 'Insufficient justification' Rejects a specific access request. .INPUTS System.String. RequestId can be piped in by value or by property name. .OUTPUTS psSCA.AccessRequest .LINK https://api-docs.cyberark.com/access-request-api/docs/access-request-api #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')] [OutputType('psSCA.AccessRequest')] param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [string]$RequestId, [Parameter()] [string]$Reason, [Parameter()] [object]$Session ) process { if ($PSCmdlet.ShouldProcess($RequestId, 'Reject Secure Cloud Access request')) { $body = @{ decision = 'Reject'; reason = $Reason } Invoke-SCARequest -Session $Session -Service 'UAR' -Method POST -Path '/workflows/requests/{requestId}/finalize' ` -PathParameters @{ requestId = $RequestId } -Body $body -Operation 'Deny-SCAAccessRequest' -TypeName 'psSCA.AccessRequest' } } } |