Public/Policies/Get-SCAAccessPolicy.ps1
|
function Get-SCAAccessPolicy { <# .SYNOPSIS Gets access control policies that govern zero-standing-privilege cloud console access. .DESCRIPTION Calls the Access Control Policies API (GET /policies or GET /policies/{policyId}), which is CyberArk's current, non-deprecated policy engine for cloud console, infrastructure, database, and group access. This is the API CyberArk recommends over the legacy SCA Policies API. .PARAMETER PolicyId Return a single policy by ID. Omit to list every policy. .PARAMETER Session A psSCA.Session object or session name. Defaults to the current default session. .EXAMPLE Get-SCAAccessPolicy Lists every access control policy in the tenant. .EXAMPLE Get-SCAAccessPolicy -PolicyId 'a1b2c3d4-policy-id' Gets a specific policy by ID. .INPUTS System.String. PolicyId can be piped in by value or by property name. .OUTPUTS psSCA.AccessPolicy .LINK https://api-docs.cyberark.com/uap-schema-api/docs/access-control-policies-api #> [CmdletBinding()] [OutputType('psSCA.AccessPolicy')] param( [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [string]$PolicyId, [Parameter()] [object]$Session ) process { if ($PolicyId) { Invoke-SCARequest -Session $Session -Service 'UAP' -Method GET -Path '/policies/{policyId}' ` -PathParameters @{ policyId = $PolicyId } -Operation 'Get-SCAAccessPolicy' -TypeName 'psSCA.AccessPolicy' } else { Invoke-SCARequest -Session $Session -Service 'UAP' -Method GET -Path '/policies' ` -Operation 'Get-SCAAccessPolicy' -TypeName 'psSCA.AccessPolicy' } } } |