Public/Curanet/M365/Get-CuranetM365UserLicenses.ps1

function Get-CuranetM365UserLicenses() {
    param(
        [Parameter(Mandatory)]
        [string] $CustomerId,
        [Parameter(Mandatory)]
        [string] $UserId
    )

    Connect-CuranetM365API -CustomerId $CustomerId

    $Response = Invoke-WebRequest -Method GET -Authentication Bearer -Token (ConvertTo-SecureString $Global:CuranetM365APIToken.access_token -AsPlainText -Force) -Uri "https://office365.curanet.dk/api/user/$($UserId)/License"

    if($Response.StatusCode -eq 200) {
        $JsonResponse = $Response.Content | ConvertFrom-Json
        return $JsonResponse
    }
    else {
        throw "Failed to get M365 license information"
    }
}