Public/Get-GCGroups.ps1

<#
.SYNOPSIS
    Retrieves a list of groups from Genesys Cloud.

.DESCRIPTION
    Queries the Genesys Cloud API to retrieve a paginated list of groups.
    Supports sorting of results.
    API Endpoint: GET /api/v2/groups

.PARAMETER PageSize
    The number of results per page. Default is 25.

.PARAMETER PageNumber
    The page number to retrieve. Default is 1.

.PARAMETER SortOrder
    The sort order for results. Valid values are 'ascending' or 'descending'.

.EXAMPLE
    Get-GCGroups
    Retrieves the first page of groups with default page size.

.EXAMPLE
    Get-GCGroups -PageSize 50 -SortOrder 'ascending'
    Retrieves groups with 50 results per page sorted in ascending order.

.NOTES
    Genesys Cloud API: GET /api/v2/groups
#>

function Get-GCGroups {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $false)]
        [int]$PageSize = 25,

        [Parameter(Mandatory = $false)]
        [int]$PageNumber = 1,

        [Parameter(Mandatory = $false)]
        [string]$SortOrder
    )

    $queryParams = @{
        pageSize   = $PageSize
        pageNumber = $PageNumber
    }

    if ($SortOrder) { $queryParams['sortOrder'] = $SortOrder }

    $endpoint = "groups"
    return Invoke-GCApiRequest -Endpoint $endpoint -Method GET -QueryParameters $queryParams
}