Public/Users/Update-AspireUsers.ps1

<#
.SYNOPSIS
    Updates an existing user in the Aspire API.
.DESCRIPTION
    Uses Invoke-AspireRequest to perform a PUT request to the /Users endpoint.
.PARAMETER UserId
    The ID of the user to update (required).
.PARAMETER AllBranchAccess
    Whether the user has access to all branches (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).
.PARAMETER Password
    The password for the user (optional).
.OUTPUTS
    The response from the API containing the result.
.EXAMPLE
    Update-AspireUsers -UserId 1 -AllBranchAccess $true -Active $true -UserRoles @(1,2)
#>

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

    $body = @{
        UserId = $UserId
        AllBranchAccess = $AllBranchAccess
        Active = $Active
        UserRoles = $UserRoles
    }

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

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