Public/Requests/New-SCAAccessRequest.ps1
|
function New-SCAAccessRequest { <# .SYNOPSIS Submits a new access request. .DESCRIPTION Calls POST /workflows/requests on the Access Requests API. Request forms are tenant-configurable (see Get-SCAAccessRequestForm), so the request body is accepted as-is rather than constrained to a fixed set of fields psSCA assumes in advance. .PARAMETER InputObject The access request body, as a hashtable or PSCustomObject matching the SubmitAccessRequest schema for your tenant's configured request form. .PARAMETER Session A psSCA.Session object or session name. Defaults to the current default session. .EXAMPLE New-SCAAccessRequest -InputObject @{ targetCategory = 'CloudConsole'; reason = 'Investigate incident 4471' } Submits a new access request. Confirm the required fields for your tenant's request form via Get-SCAAccessRequestForm first. .INPUTS System.Object. Accepts a request body via the pipeline. .OUTPUTS psSCA.AccessRequest .NOTES Each pipeline object is submitted independently; one failed request does not stop subsequent ones unless -ErrorAction Stop is specified. .LINK https://api-docs.cyberark.com/access-request-api/docs/access-request-api #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')] [OutputType('psSCA.AccessRequest')] param( [Parameter(Mandatory, ValueFromPipeline)] [object]$InputObject, [Parameter()] [object]$Session ) process { $reason = if ($InputObject -is [hashtable]) { $InputObject['reason'] } else { $InputObject.reason } $target = if ($reason) { $reason } else { 'new access request' } if ($PSCmdlet.ShouldProcess($target, 'Submit Secure Cloud Access request')) { Invoke-SCARequest -Session $Session -Service 'UAR' -Method POST -Path '/workflows/requests' ` -Body $InputObject -Operation 'New-SCAAccessRequest' -TypeName 'psSCA.AccessRequest' } } } |