Skip to main content

There are two methods to assign a Microsoft 365 license. One way is to assign the license directly, and the other is to add the user to a group linked to the license, known as group-based licensing. The preferable method is group-based licensing because it’s easier to maintain and for auditing purposes. In this article, you will learn how to check if a Microsoft 365 user license is direct assigned or inherited from a group.

Check user license assignment type in Microsoft Entra admin center

To check if the Microsoft 365 user license is direct assigned or inherited from a group in Microsoft Entra admin center, follow the below steps:

  1. Sign in to Microsoft Entra admin center
  2. Expand Identity > Billing > Licenses
  3. Click All products
  4. Click the Microsoft product name
Microsoft 365 user license all products
  1. Check the column Assignment Paths if the user is direct assigned or inherited from a group
Microsoft 365 user license assignment paths

Note: It’s recommended to Assign Microsoft 365 licenses with group-based licensing and not direct so you can manage it easily.

Check user license assignment type with PowerShell

To check if the Microsoft 365 user license is direct assigned or inherited from a group with Microsoft Graph PowerShell, follow these steps:

Step 1. Install Microsoft Graph PowerShell

Run Windows PowerShell as administrator and Install Microsoft Graph PowerShell.

Install-Module Microsoft.Graph -Force
Install-Module Microsoft.Graph.Beta -AllowClobber -Force

Important: Always install the Microsoft Graph PowerShell and Microsoft Graph Beta PowerShell modules. That’s because some cmdlets are not yet available in the final version, and they will not work. Update both modules to the latest version before you run a cmdlet or script to prevent errors and incorrect results.

Step 2. Prepare Get-LicenseAssignment PowerShell script

Create two folders on the (C:) drive:

  • Temp
  • Scripts

Download the Get-LicenseAssignment.ps1 PowerShell script and place it in C:\scripts folder. The script will export the CSV file to the C:\temp folder.

Ensure the file is unblocked to prevent errors when running the script..

Another option is to copy and paste the below code into Notepad. Give it the name Get-LicenseAssignment.ps1 and place it in the C:\scripts folder.

<#
    .SYNOPSIS
    Get-LicenseAssignment.ps1

    .DESCRIPTION
    The script will export all Microsoft 365 users license assignment to CSV file.

    .LINK
    www.traceroute.net/microsoft-365-user-license-direct-assigned-or-inherited-from-group/

    .NOTES
    Written by: traceroute
    Website:    www.traceroute.net
    LinkedIn:   linkedin.com/in/traceroute

    .CHANGELOG
    V1.00, 03/04/2024 - Initial version
#>

# Connect to Microsoft Graph
Connect-MgGraph -Scopes "User.Read.All"

# Get all users using Get-MgUser with a filter
$users = Get-MgUser -All -Property AssignedLicenses, LicenseAssignmentStates, DisplayName |
Select-Object DisplayName, AssignedLicenses -ExpandProperty LicenseAssignmentStates

$output = @()

# Loop through all users and get the AssignedByGroup Details which will list the groupId
foreach ($user in $users) {
    # Get the group ID if AssignedByGroup is not empty
    if ($user.AssignedByGroup -ne $null) {
        $groupId = $user.AssignedByGroup
        $groupName = Get-MgGroup -GroupId $groupId | Select-Object -ExpandProperty DisplayName
        Write-Host "$($user.DisplayName) is assigned by group - $($groupName)" -ErrorAction SilentlyContinue -ForegroundColor Cyan
        $result = [pscustomobject]@{
            User      = $user.DisplayName
            Assigned  = "Group"
            GroupName = $groupName
            GroupId   = $groupId
        }
        $output += $result
    }

    else {
        $result = [pscustomobject]@{
            User      = $user.DisplayName
            Assigned  = "Direct"
            GroupName = "N/A"
            GroupId   = "N/A"
        }
        $output += $result
        Write-Host "$($user.DisplayName) is direct assigned" -ErrorAction SilentlyContinue -ForegroundColor Yellow
    }
}

# Display the results
$output | Export-Csv -Path "C:\temp\LicenseAssignments.csv" -NoTypeInformation -Encoding utf8
$output | Out-GridView -Title "License Assignments"
  • Line 58: Edit the CSV file path

Step 3. Run Get-LicenseAssignment PowerShell script

Run the below command to run the script Get-LicenseAssignment.ps1.

c:\scripts\.\Get-LicenseAssignment.ps1

The PowerShell output shows if the license is inherited by a group or is direct assigned.

Note: The output shows if there are multiple groups assigned to a user or if the user has both a license direct assigned and assigned by group.

Alison Bell is assigned by group - O365_Licenses_E3_Base
Alison Bell is assigned by group - O365_Licenses_E3_Exchange
Boris Campbell is assigned by group - O365_Licenses_E3_Exchange
Carol Baker is assigned by group - O365_Licenses_E3_Exchange
CloudOnly is direct assigned
Edward Lincoln is assigned by group - O365_Licenses_E3_Exchange
Jeffrey Welch is direct assigned
Jérôme User is direct assigned
Lauren Russell is direct assigned
Phil Peters is direct assigned
Richard Grant is assigned by group - O365_Licenses_E3_Exchange
Richard Grant is direct assigned
Zoë Roberts is direct assigned
Zoë Roberts is assigned by group - O365_Licenses_E3_Exchange

An Out-GridView will show all the information you need.

Microsoft 365 user license assignment paths Out-GridView

Step 4. Open license assignment report

The Get-LicenseAssignment.ps1 PowerShell script exports all Microsoft 365 users license assignments to CSV file.

Find the file LicenseAssignments.csv in the path C:\temp.

Open the CSV file with your favorite application. In our example, it’s Microsoft Excel.

Microsoft 365 user license assignment paths CSV file

The Microsoft 365 user license assignment type report looks great.

Leave a Reply