Manually assigning Microsoft 365 licenses every time someone joins, transfers, or leaves a department wastes time and leads to unused paid seats. By combining Microsoft Entra ID (formerly Azure AD) Dynamic Groups with Group-Based Licensing, you can automate the entire process.
In this step-by-step guide, you will learn how to automatically assign Microsoft licenses to based on attributes using dynamic groups.
The below example shows how MS Project licenses get assign to HR users based on the department attributes on the user account. the same method can be used to target one or more attributes.
How Dynamic Group-Based Licensing Works
Instead of assigning a license directly to individual user accounts, you attach the license to a Dynamic Security Group. Microsoft Entra ID continuously checks user profile attributes (such as Department) and manages group membership automatically:
- New HR hire joins: Their
Departmentattribute is set toHR→ Entra ID adds them to the dynamic group → Group-based licensing automatically assigns Microsoft Project. - Employee transfers out of HR: Their
Departmentchanges toFinance→ Entra ID removes them from the group → The Microsoft Project license is automatically unassigned and returned to your pool. - Employee leaves the company: Their account is disabled → Entra ID removes them from the group → No wasted license costs.

Prerequisites
Before you start, make sure you have the following in place:
- Licensing: Every user who benefits from dynamic groups and group-based licensing requires Microsoft Entra ID P1 or P2 (included in Microsoft 365 Business Premium, E3, and E5).
- Available Seats: Enough unassigned Microsoft Project (for example, Project Plan 3 or Planner and Project Plan 3) licenses in your tenant.
- Admin Roles: At least Groups Administrator (to create the dynamic group) and License Administrator (to assign licenses).
- Clean User Data: Target HR users must have their
Departmentattribute populated consistently and a validUsageLocationset.
Note: Microsoft moved license assignment UI controls from the Entra admin center to the Microsoft 365 admin center. In this guide, you will create the dynamic group in Entra ID and assign the MS Project license in the Microsoft 365 admin center.
Step 1: Create the HR Dynamic Security Group
First, create a security group in Microsoft Entra ID that automatically collects all active HR users.
- Sign in to the Microsoft Entra admin center (
https://entra.microsoft.com). - In the left menu, navigate to Identity → Groups → All groups.
- Click New group.
- Configure the group details:
- Group type: Security
- Group name:
SG-Dyn-Lic-HR-Project - Group description:
Dynamic group for auto-assigning MS Project licenses to active HR users. - Membership type: Dynamic User
- Click Add dynamic query.
Configure the Dynamic Membership Rule
On the Dynamic membership rules screen, click Edit next to the Rule syntax box and paste the following expression:
(user.department -eq "HR") and (user.accountEnabled -eq true)
Tip: If your directory uses both HR and Human Resources in the Department field, use the -in operator instead so nobody is missed:(user.department -in ["HR", "Human Resources"]) and (user.accountEnabled -eq true)
- Click OK, then click Save on the dynamic query page.
- Click Create to provision the group.
Optional: Create the Group Using PowerShell
If you prefer automation, you can create the exact same dynamic group using the Microsoft Graph PowerShell SDK:
Connect-MgGraph -Scopes "Group.ReadWrite.All"
New-MgGroup -DisplayName "SG-Dyn-Lic-HR-Project" `
-Description "Dynamic group for auto-assigning MS Project licenses to active HR users" `
-MailEnabled:$false `
-MailNickname "SGDynLicHRProject" `
-SecurityEnabled:$true `
-GroupTypes @("DynamicMembership") `
-MembershipRule '(user.department -eq "HR") and (user.accountEnabled -eq true)' `
-MembershipRuleProcessingState "On"
Step 2: Validate Your Dynamic Rule
Before attaching paid licenses to the group, verify that your rule only matches the right HR users:
- Open SG-Dyn-Lic-HR-Project under Identity → Groups → All groups.
- Select Dynamic membership rules under Manage, then click the Validate Rules (Preview) tab.
- Click Add users and select one active HR user and one non-HR user (or disabled HR account).
- Click Validate. Confirm that the active HR user shows a green checkmark and the non-HR user shows a red cross.
Step 3: Assign the MS Project License to the Group
Now link your Microsoft Project subscription to the dynamic group using the Microsoft 365 admin center:
- Sign in to the Microsoft 365 admin center (
https://admin.microsoft.com). - In the left navigation pane, go to Billing → Licenses.
- Click on your Microsoft Project license (for example, Project Plan 3 or Planner and Project Plan 3).
- Select the Groups tab, then click + Assign licenses.
- Search for and select SG-Dyn-Lic-HR-Project.
- (Optional) Expand Turn apps and services on or off if you want to enable or disable specific sub-services within the license.
- Click Assign, then close the panel.
Step 4: Verify License Assignment
Dynamic group evaluation and license processing usually finish within a few minutes (though larger tenants can take longer). To confirm it worked:
- In the Microsoft 365 admin center, go to Billing → Licenses and open your Microsoft Project license.
- Click the Groups tab and check the status next to SG-Dyn-Lic-HR-Project—it should show Active (or All licenses assigned).
- Open one of your HR users under Users → Active users → Licenses and apps to confirm that Microsoft Project is checked and marked as inherited from the group.
Common Pitfalls and Best Practices
- Missing Usage Location: If a user has no
UsageLocationset, license assignment can fail or default to the tenant’s country. Always setUsageLocationduring user onboarding. - Insufficient Licenses: If your HR team grows past your available MS Project seat count, new members will appear under Billing → Licenses → [Product] → Errors & issues. Once you purchase more seats, select the affected users and click Reprocess.
- Always Include
accountEnabled -eq true: Without this condition, disabled accounts remain in the group and continue holding paid Microsoft Project licenses. - Avoid Nested Groups: Group-based licensing only applies to direct members of the group—nested groups are not supported.
Warning: If an HR user previously had Microsoft Project assigned directly, they will briefly have both a direct and group-inherited assignment. Once you confirm the group assignment is active, remove the direct assignment so future department transfers automatically reclaim the license.
Conclusion
Combining Microsoft Entra ID Dynamic Groups with Group-Based Licensing turns software provisioning into a zero-touch workflow. With SG-Dyn-Lic-HR-Project in place, every active HR employee automatically gets Microsoft Project on day one, and licenses are reclaimed the moment someone changes departments or leaves the organization.