Public/Policies/Set-SIAPolicy.ps1
|
function Set-SIAPolicy { <# .SYNOPSIS Edits a unified access control policy. .DESCRIPTION Updates a policy in CyberArk's unified Access Control Policies engine. -Body stays generic: CyberArk's schema for a VM policy alone (InfrastructureVirtualMachineAccessPolicy) requires four top-level nested objects - metadata, conditions (InfrastructureConditions), targets (InfrastructureVirtualMachineTarget), and behavior (InfrastructureVirtualMachineBehavior) - each with their own required sub-fields not captured during development. .PARAMETER Id The policy's ID, as returned by Get-SIAPolicy. .PARAMETER Body The request body. For VM access, matches InfrastructureVirtualMachineAccessPolicy; other target types use a different schema - see the linked API documentation for the exact shape. .EXAMPLE Set-SIAPolicy -Id 'policy-01' -Body $updatedDefinition Updates the specified access control policy. .INPUTS psSIA.Policy .OUTPUTS psSIA.Policy .LINK https://api-docs.cyberark.com/uap-schema-api/docs/access-control-policies-api #> [CmdletBinding(SupportsShouldProcess)] [OutputType('psSIA.Policy')] param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('policyId')] [string]$Id, [Parameter(Mandatory)] $Body ) process { if ($PSCmdlet.ShouldProcess($Id, 'Edit access control policy')) { Invoke-SIARequest -Method PUT -Path "/policies/$Id" -Body $Body -Service Uap | ConvertFrom-SIAResponse -TypeName 'psSIA.Policy' } } } |