๐ฅ Recipe ยท User & Group Management
Create an Entra ID User, Assign an E5 License, and Grant Global Administrator Role
Provision a new Microsoft 365 user with mailbox, E5 licensing, and tenant-wide admin privileges
Complexity
Intermediate
Impact
privileged-access + user-provisioning + licensing + identity
Context
Why This Matters
New-hire provisioning for privileged accounts is one of the most common โ and most sensitive โ IT administration workflows. When a new administrator, executive, or power user joins the organization, IT must create their Entra ID identity, provision an Exchange Online mailbox, assign the appropriate Microsoft 365 license (E5 for full security and compliance tooling), and grant the required directory role.
This recipe walks through the end-to-end creation of a fully provisioned Entra ID user with a Microsoft 365 E5 license and the Global Administrator role. Because Global Administrator is the most powerful role in the tenant, this workflow should be reserved for break-glass accounts, founding IT staff, or identity team members โ and ideally paired with Privileged Identity Management (PIM) for just-in-time activation.
Run this recipe when: onboarding a new IT administrator, creating a dedicated break-glass account, or provisioning a senior technical user who legitimately requires tenant-wide admin rights and full E5 capabilities (Defender, Purview, Entra ID P2, etc.).
Expected Outcomes
- A new Entra ID user account with
displayName,givenName,surname,mailNickname, anduserPrincipalNamepopulated - A secure, randomly generated 16-character initial password with
forceChangePasswordNextSignInenabled - A Microsoft 365 E5 license assigned (which automatically provisions the Exchange Online mailbox, Teams, SharePoint, OneDrive, Defender, and Purview entitlements)
- Global Administrator directory role membership
usageLocationset (required for license assignment)- Verification output confirming account, license, mailbox, and role assignment are all in place
Risks & Considerations
Privileged Role Warnings
- Global Administrator is the highest-privilege role in M365. Microsoft recommends fewer than 5 permanent Global Admins per tenant. Consider assigning a lower-privilege role (User Administrator, Exchange Administrator, etc.) if the user does not need full tenant control.
- Enforce MFA immediately on any newly created Global Admin. A Conditional Access policy requiring MFA for admin roles is strongly recommended before the first sign-in.
- Use PIM for just-in-time activation when possible. Assign the role as eligible rather than active so the user must justify and activate the role for each session.
Licensing Gotchas
usageLocationmust be set on the user before license assignment or the Graph call will fail with a 400 error.- Confirm prepaid E5 units are available (
prepaidUnits.enabled - consumedUnits > 0) before assignment. - Mailbox provisioning is asynchronous โ the mailbox may take 5โ15 minutes to become fully usable after license assignment.
Password Handling
- Deliver the initial password out-of-band (e.g., via verified SMS or in person) โ never in the same channel as the UPN.
- Always set
forceChangePasswordNextSignIn: trueso the user sets their own password on first login.
Required Permissions
| Permission | Why It's Needed |
|---|---|
| User.ReadWrite.All | Create the user account and update profile fields |
| Directory.ReadWrite.All | Assign licenses and directory role memberships |
| RoleManagement.ReadWrite.Directory | Add the user to the Global Administrator directory role |
| Organization.Read.All | Enumerate subscribed SKUs to confirm E5 license availability |
| Domain.Read.All | Resolve the tenant's verified default domain for the UPN suffix |
The fastest way to get this done: just ask Dex. Copy the prompt below and paste it into your Dex conversation.
For IT Admins
Paste into Dex Pro
Create the User in Microsoft 365 Admin Center
- Sign in to the Microsoft 365 Admin Center as a Global Administrator or User Administrator.
- Navigate to .
- Fill in the Basics tab:
- First name:
{first_name} - Last name:
{last_name} - Display name:
{display_name} - Username:
{mail_nickname}@ select your verified domain
- First name:
- Choose Automatically create a password (or set one manually) and check Require this user to change their password when they first sign in.
- Check Send the password in email upon completion only if your security policy permits it โ otherwise deliver the password out-of-band.
- Click Next.
Assign the E5 License
- On the Product licenses tab, set the Location to the user's country (e.g., United States).
- Toggle Microsoft 365 E5 (or Microsoft 365 E5 Developer) to On.
- Review the included apps and services โ leave defaults unless you need to carve out specific service plans.
- Click Next.
Grant the Global Administrator Role
- On the Optional settings tab, expand Roles.
- Select Admin center access, then check Global administrator.
- Enter an alternate email address for password recovery (required for admin roles).
- Click Next, review the summary, and click Finish adding.
Verify Provisioning
- Navigate to and confirm the license shows as assigned and the mailbox status shows as provisioned (may take 5โ15 minutes).
- In the Entra admin center, navigate to and confirm the user appears as an active assignment.
- Immediately either enable Security Defaults or apply a Conditional Access policy requiring MFA for this user.
Graph API Workflow
This workflow requires four sequential calls: resolve the domain, create the user, assign the license, and add the role member. All calls target https://graph.microsoft.com.
Step 1 โ Resolve the Default Verified Domain
GET /v1.0/domains?$select=id,isDefault,isVerifiedFind the entry where isDefault: true and isVerified: true. Use its id as the UPN suffix.
Step 2 โ Enumerate Subscribed SKUs
GET /v1.0/subscribedSkus?$select=skuId,skuPartNumber,capabilityStatus,consumedUnits,prepaidUnitsLocate the SKU with skuPartNumber of SPE_E5 (production) or DEVELOPERPACK_E5 (dev tenant). Confirm prepaidUnits.enabled - consumedUnits > 0. Record the skuId.
Step 3 โ Resolve the Global Administrator Role ID
GET /v1.0/directoryRoles?$filter=displayName eq 'Global Administrator'If the role is not returned, it has not been activated in the tenant yet. Activate it with POST /v1.0/directoryRoles using the template ID 62e90394-69f5-4237-9190-012177145e10.
Step 4 โ Create the User
POST /v1.0/users
Content-Type: application/json
{
"accountEnabled": true,
"displayName": "{display_name}",
"givenName": "{first_name}",
"surname": "{last_name}",
"mailNickname": "{mail_nickname}",
"userPrincipalName": "{mail_nickname}@{verified_domain}",
"usageLocation": "US",
"passwordProfile": {
"forceChangePasswordNextSignIn": true,
"password": "{generated_password}"
}
}Response 201 Created returns the new user's id (GUID). Capture it for subsequent calls.
Step 5 โ Assign the E5 License
POST /v1.0/users/{user_id}/assignLicense
Content-Type: application/json
{
"addLicenses": [{ "skuId": "{e5_sku_id}" }],
"removeLicenses": []
}Response 200 OK. The Exchange Online mailbox begins provisioning immediately โ the mail property will populate within a few minutes.
Step 6 โ Add User to Global Administrator Role
POST /v1.0/directoryRoles/{role_id}/members/$ref
Content-Type: application/json
{
"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/{user_id}"
}Response 204 No Content.
Step 7 โ Verification
GET /v1.0/users/{user_id}?$select=id,displayName,userPrincipalName,mail,accountEnabled,usageLocation
GET /v1.0/users/{user_id}/licenseDetails
GET /v1.0/directoryRoles/{role_id}/members?$select=id,displayName,userPrincipalNameAutomate With Microsoft Graph PowerShell
The script below uses the Microsoft.Graph PowerShell SDK to perform the full provisioning flow, generate a secure password, and return a structured result object. It handles the common ordering pitfall (usageLocation must precede license assignment) and activates the Global Administrator role template if the role is not yet instantiated.
Prerequisites
- PowerShell 7+ recommended
- Microsoft Graph PowerShell SDK:
Install-Module Microsoft.Graph -Scope CurrentUser - Sign in with an account holding User Administrator + Privileged Role Administrator (or Global Administrator)
Usage
# Dot-source or run directly:
.\New-EntraAdminUser.ps1 -FirstName 'Janna' -LastName 'Pak' -MailNickname 'janna.pak' -LicenseSkuPartNumber 'SPE_E5'What the Script Does
- Connects to Graph with the minimum required scopes.
- Resolves the default verified domain for the UPN suffix.
- Validates the target SKU exists and has available units.
- Checks for existing users matching the UPN (fails fast on duplicates).
- Generates a 16-character cryptographically random password.
- Creates the user with
usageLocationset. - Assigns the E5 license.
- Activates the Global Administrator role template if needed, then adds the user as a member.
- Verifies and returns a summary object including the initial password.
Next steps