Public/Policies/Set-SCAAccessPolicy.ps1
|
function Set-SCAAccessPolicy { <# .SYNOPSIS Updates an existing access control policy. .DESCRIPTION Calls PUT /policies/{policyId} on the Access Control Policies API to replace an existing policy's definition. .PARAMETER PolicyId The policy to update. .PARAMETER InputObject The updated policy document, as a hashtable or PSCustomObject matching CyberArk's policy schema. Typically built by modifying the object returned from Get-SCAAccessPolicy. .PARAMETER Session A psSCA.Session object or session name. Defaults to the current default session. .EXAMPLE $policy = Get-SCAAccessPolicy -PolicyId 'a1b2c3d4-policy-id' $policy.status = 'Inactive' Set-SCAAccessPolicy -PolicyId $policy.policyId -InputObject $policy Disables an existing policy. .INPUTS None. .OUTPUTS psSCA.AccessPolicy .NOTES Confirm the exact request body fields against CyberArk's published schema before relying on this in an automated pipeline. .LINK https://api-docs.cyberark.com/uap-schema-api/docs/access-control-policies-api #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')] [OutputType('psSCA.AccessPolicy')] param( [Parameter(Mandatory)] [string]$PolicyId, [Parameter(Mandatory)] [object]$InputObject, [Parameter()] [object]$Session ) if ($PSCmdlet.ShouldProcess($PolicyId, 'Update Secure Cloud Access policy')) { Invoke-SCARequest -Session $Session -Service 'UAP' -Method PUT -Path '/policies/{policyId}' ` -PathParameters @{ policyId = $PolicyId } -Body $InputObject -Operation 'Set-SCAAccessPolicy' -TypeName 'psSCA.AccessPolicy' } } |