# Generates an MSOL User License Report

Function Get-MGUserLicenseAssignmentState {
    Gathers a users license state using a direct Graph call.
    There is no cmdlet for this one.
    Uses Invoke-MgGraphRequest to request the licnese assignement information for a user
    What comes back is JSON encoded data that is converted to PS objects and returned to the caller.
    UserID of the user to gather the information for.
    PS Objects with license assignment information.
    Get-MGUserLicenseAssignmentState -UserID 123456
    Returns the license assignement information to the calling function.

        [Parameter(Mandatory = $true)]

    # Make sure we have the connection to MSOL
    Write-SimpleLogFile "Gathering user license assignment state"

    $Uri = "" + $UserID + "?`$select=licenseAssignmentStates"
    # clear any errors
    # Try to retrieve the state
    Try { $state = Invoke-MgGraphRequest -Uri $Uri -OutputType JSON -ErrorAction Stop }
    catch {
        Write-SimpleLogfile ("Error Encountered: " + $_)
        Write-Error -message $_ -ErrorAction Stop 
    Return ($state | ConvertFrom-JSON).licenseAssignmentStates