Public/Invoke-GCUserSearch.ps1

<#
.SYNOPSIS
    Searches for users in Genesys Cloud.

.DESCRIPTION
    Performs a user search in Genesys Cloud by sending a POST request with search criteria.
    Supports complex search queries with multiple fields, sorting, and pagination.
    API Endpoint: POST /api/v2/users/search

.PARAMETER Body
    The request body containing the search criteria. Accepts a hashtable or JSON string.
    Should include a 'query' array with search terms and optionally 'sortOrder', 'sortBy',
    'pageSize', and 'pageNumber'.

.EXAMPLE
    Invoke-GCUserSearch -Body @{ query = @(@{ type = 'EXACT'; fields = @('email'); values = @('john@example.com') }) }
    Searches for users with the exact email address.

.EXAMPLE
    Invoke-GCUserSearch -Body @{ query = @(@{ type = 'CONTAINS'; fields = @('name'); value = 'John' }); pageSize = 50 }
    Searches for users whose name contains 'John' with 50 results per page.

.NOTES
    Genesys Cloud API: POST /api/v2/users/search
#>

function Invoke-GCUserSearch {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [object]$Body
    )

    $endpoint = "users/search"
    return Invoke-GCApiRequest -Endpoint $endpoint -Method POST -Body $Body
}