Public/Users/New-AspireUsers.ps1

<#
.SYNOPSIS
    Creates a new user in the Aspire API.
.DESCRIPTION
    Uses Invoke-AspireRequest to perform a POST request to the /Users endpoint.
.PARAMETER AllBranchAccess
    Whether the user has access to all branches (required).
.PARAMETER ExternalContactReference
    The external contact reference (required).
.PARAMETER Password
    The password for the user (required).
.PARAMETER Active
    Whether the user is active (required).
.PARAMETER UserRoles
    Array of user role IDs (required).
.PARAMETER BranchAccess
    Array of branch access IDs (optional).
.OUTPUTS
    The response from the API containing the result.
.EXAMPLE
    New-AspireUsers -AllBranchAccess $true -ExternalContactReference "ref123" -Password "pass" -Active $true -UserRoles @(1,2)
#>

function New-AspireUsers {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [bool]$AllBranchAccess,
        [Parameter(Mandatory = $true)]
        [string]$ExternalContactReference,
        [Parameter(Mandatory = $true)]
        [string]$Password,
        [Parameter(Mandatory = $true)]
        [bool]$Active,
        [Parameter(Mandatory = $true)]
        [int[]]$UserRoles,
        [int[]]$BranchAccess = $null
    )

    $body = @{
        AllBranchAccess = $AllBranchAccess
        ExternalContactReference = $ExternalContactReference
        Password = $Password
        Active = $Active
        UserRoles = $UserRoles
    }

    if ($BranchAccess) {
        $body.BranchAccess = $BranchAccess
    }

    return Invoke-AspireRequest -Method POST -Path "/Users" -Body $body
}