Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.
🚀 Launch ToolkitGroup-based licensing in Microsoft Entra ID (formerly Azure Active Directory) simplifies license management by automatically assigning licenses to users through groups. However, sometimes users might not receive the expected licenses — a sign of broken or inconsistent group-based license assignments.
This guide explains how to identify such users using Microsoft Graph PowerShell.
When group-based licensing breaks, affected users may:
These inconsistencies can be fixed using Invoke-MgLicenseUser, but first, you need to identify the affected users.
Start by connecting to Microsoft Graph with the required permissions:
Connect-MgGraph -Scopes "User.Read.All", "Directory.Read.All"
Verify connection:
Get-MgContext
You can identify unlicensed users using the following command:
Get-MgUser -All -Filter "assignedLicenses/`$count eq 0 and userType eq 'Member'" -ConsistencyLevel eventual -CountVariable Records
Explanation:
Once you identify unlicensed users, check if they belong to groups that assign licenses:
Get-MgUserMemberOf -UserId "<UserId>" | Select-Object DisplayName, Id
Note: you’ll have to pass the group ids returned by Get-MgUserMemberOf to Get-MgGroup cmdlet to fetch the group display name.
If the user appears in licensed groups but has no assigned licenses, the group-based assignment is likely broken.
You can export the unlicensed users list to a CSV file for review:
Get-MgUser -All -Filter "assignedLicenses/`$count eq 0 and userType eq 'Member'" -ConsistencyLevel eventual -CountVariable Records | Export-Csv "UnlicensedUsers.csv" -NoTypeInformation
Once you confirm affected users, reprocess their group-based license assignments using the following cmdlet:
Invoke-MgLicenseUser -UserId "<UserId>"
This command triggers Microsoft Entra ID to re-evaluate and reassign all group-based licenses for that user.
Tips
| Error | Cause | Solution |
|---|---|---|
| PermissionDenied | Missing permissions for Graph operations. | Connect with Directory.ReadWrite.All scope. |
| Request_ResourceNotFound | User or group doesn’t exist or was deleted. | Validate the UserId or group ID. |
| InvalidFilterClause | Incorrect $count filter used without -ConsistencyLevel eventual. | Add -ConsistencyLevel eventual to the cmdlet. |
Broken group-based license assignments can silently affect users and cause access issues across Microsoft 365 services.
By combining Get-MgUser filters with group membership checks, you can easily detect users who aren’t receiving their licenses as expected. Once identified, the Invoke-MgLicenseUser cmdlet can quickly reprocess their assignments, ensuring consistency and compliance within your tenant.
Regular checks using this method can save administrators hours of troubleshooting time while maintaining a smooth licensing experience for users.
Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.
Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.
© Your Site Name. All Rights Reserved. Design by HTML Codex