Public/Workspaces/Get-SCAWorkspaceDelegation.ps1

function Get-SCAWorkspaceDelegation {
    <#
    .SYNOPSIS
        Searches workspace delegations.
    .DESCRIPTION
        Calls POST /delegations/workspace/search on the Workspace Delegation API. This is a
        search-style operation implemented as POST; it is idempotent (a pure query) so
        Invoke-SCARequest retries it on transient failures the same way it would a GET.
    .PARAMETER Filter
        Raw filter fields merged into the request body, matching the FilterOptions schema. See the
        link below for the current filter fields.
    .PARAMETER Session
        A psSCA.Session object or session name. Defaults to the current default session.
    .EXAMPLE
        Get-SCAWorkspaceDelegation

        Lists every workspace delegation visible to the caller.
    .INPUTS
        None.
    .OUTPUTS
        psSCA.WorkspaceDelegation
    .LINK
        https://api-docs.cyberark.com/workspace-delegation/docs/workspace-delegation
    #>

    [CmdletBinding()]
    [OutputType('psSCA.WorkspaceDelegation')]
    param(
        [Parameter()]
        [hashtable]$Filter,

        [Parameter()]
        [object]$Session
    )

    $body = if ($Filter) { $Filter } else { @{} }

    Invoke-SCARequest -Session $Session -Service 'CEM' -Method POST -Path '/delegations/workspace/search' `
        -Body $body -Operation 'Get-SCAWorkspaceDelegation' -TypeName 'psSCA.WorkspaceDelegation' -Idempotent
}