Public/Policies/New-SIAPolicy.ps1
|
function New-SIAPolicy { <# .SYNOPSIS Creates a unified access control policy. .DESCRIPTION Creates a policy in CyberArk's unified Access Control Policies engine, covering VM access, database access, cloud service access, and Entra ID group membership. -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. Consider validating the body with Test-SIAPolicy first. .PARAMETER Body The request body. For VM access, matches InfrastructureVirtualMachineAccessPolicy; other target types use a different schema (CloudConsoleAccessPolicy, GroupAccessPolicy, and so on) - see the linked API documentation for the exact shape. .EXAMPLE New-SIAPolicy -Body $policyDefinition Creates a new access control policy from a prepared definition. .INPUTS None. .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)] $Body ) if ($PSCmdlet.ShouldProcess('SIA', 'Create access control policy')) { Invoke-SIARequest -Method POST -Path '/policies' -Body $Body -Service Uap | ConvertFrom-SIAResponse -TypeName 'psSIA.Policy' } } |