๐ฅ Recipe ยท User & Group Management
Create a New Entra ID User and Email Temporary Credentials
Provision an unlicensed Entra ID account with a secure temporary password and deliver the credentials to a designated recipient
Complexity
Beginner
Impact
onboarding + identity + user-lifecycle + credentials
Context
Why This Matters
Why this recipe exists
New-hire and contractor onboarding frequently requires a bare Entra ID identity before licensing, group membership, or manager assignment is finalized. A common pattern is to create an enabled account with a one-time password, force a password change at first sign-in, and hand the temporary credentials off to a hiring manager, IT coordinator, or the user's personal email so they can complete self-onboarding.
This recipe covers that exact workflow: verify the UPN is free, generate a strong temporary password, create the user with forceChangePasswordNextSignIn = true, and surface the credentials to a trusted recipient โ all without assigning a license.
When to use it
- Day-zero onboarding when licensing decisions are still pending
- Creating accounts for contractors or external staff who do not need a mailbox
- Pre-provisioning identities for downstream automation (group sync, SCIM, HRIS)
Expected Outcomes
What you'll have when done
- A new enabled Entra ID user at
{user_upn}with display name{display_name} - A 16-character cryptographically-random temporary password
forceChangePasswordNextSignInset totrueso the user must rotate the password on first login- No licenses assigned (no mailbox, no SharePoint, no Teams) โ ready for selective license assignment later
- The temporary credentials delivered to the designated recipient (manager, IT coordinator, or personal email)
Risks & Considerations
Warnings & gotchas
- Credentials in email are sensitive. Never send the password and the UPN in the same message to an untrusted channel. Prefer a password manager share, an ephemeral secrets tool, or an out-of-band channel (SMS for the password, email for the UPN).
- No license = no mailbox. The user cannot receive mail at
{user_upn}until a license with Exchange Online is assigned. Don't send onboarding mail to the new UPN โ it will bounce. - UPN collisions. Always run the existence check first. Graph returns 404 for a free UPN and 200 for an existing one; creating over an existing user fails with 400.
- Password policy. Tenants with custom banned-password lists or length requirements may reject weak generators. Use at least 14 characters and include mixed case, digits, and symbols.
- Audit trail. User creation is logged in the Entra ID audit log. Document the business justification in your ticketing system before creating the account.
- Conditional Access. If CA policies require MFA at first sign-in, ensure the user has a way to register an authenticator (TAP, phone, etc.) โ a forced password change alone will not satisfy MFA gates.
Required Permissions
| Permission | Why It's Needed |
|---|---|
| User.ReadWrite.All | Create the new user object and set initial password profile |
| User.Read.All | Check whether the target UPN already exists before creating |
| Directory.ReadWrite.All | Required for writing directory objects in some tenant configurations |
| Mail.Send | Only if delivering credentials via Graph sendMail from a service mailbox |
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 the Microsoft Entra admin center
- Sign in to the Microsoft Entra admin center at
https://entra.microsoft.comas a User Administrator or Global Administrator. - Navigate to:
Identity โ Users โ All users โ + New user โ Create new user
- On the Basics tab, fill in:
- User principal name:
{mail_nickname}(select the verified domain, e.g.@{tenant_domain}) - Display name:
{display_name} - Password: choose Auto-generate password or Let me create the password and paste a 16-character random string
- Check Account enabled
- Check Require this user to change their password when they first sign in
- User principal name:
- Skip the Properties, Assignments, and Review + create steps for license/group assignment (leave empty for an unlicensed account).
- Click Review + create, then Create.
- Copy the generated password from the confirmation screen โ it will not be shown again.
- Deliver the credentials to
{recipient_email}. Preferred: share the password via a password-manager secure link or a one-time secret service, and send the UPN separately by email.
Verify: Return to All users and confirm {user_upn} appears with Account enabled = Yes and Licenses = None.
Create the user via Microsoft Graph
Step 1 โ Check if the UPN is already in use
GET https://graph.microsoft.com/v1.0/users/{user_upn}A 404 Request_ResourceNotFound confirms the UPN is free. A 200 OK means the user already exists โ stop and reconcile.
Step 2 โ Create the user
POST https://graph.microsoft.com/v1.0/users
Content-Type: application/json
{
"accountEnabled": true,
"displayName": "{display_name}",
"mailNickname": "{mail_nickname}",
"userPrincipalName": "{user_upn}",
"passwordProfile": {
"forceChangePasswordNextSignIn": true,
"password": "{temporary_password}"
}
}Expected response (201 Created)
{
"id": "7cceb772-cbef-4cc1-886b-30487f371ecd",
"displayName": "{display_name}",
"userPrincipalName": "{user_upn}",
"mail": null
}mail is null because no Exchange Online license is assigned โ expected behavior.
Step 3 โ (Optional) Send credentials via Graph sendMail
POST https://graph.microsoft.com/v1.0/users/{sender_id}/sendMail
Content-Type: application/json
{
"message": {
"subject": "New account created: {display_name}",
"body": {
"contentType": "Text",
"content": "UPN: {user_upn}\nTemp password: {temporary_password}\nUser must change password at first sign-in."
},
"toRecipients": [
{ "emailAddress": { "address": "{recipient_email}" } }
]
}
}Security note: consider sending only the UPN via email and distributing the password via a secure secret-sharing channel.
Create the user with Microsoft Graph PowerShell
Use the Microsoft.Graph PowerShell SDK. The script generates a cryptographically-random password, creates the account, and optionally emails the credentials.
Prerequisites
Install-Module Microsoft.Graph -Scope CurrentUser- Sign-in scopes:
User.ReadWrite.All(plusMail.Sendif emailing from a service account)
Connect and run
Connect-MgGraph -Scopes "User.ReadWrite.All","Mail.Send"
# Check for existing user
$existing = Get-MgUser -Filter "userPrincipalName eq '$UserPrincipalName'" -ErrorAction SilentlyContinue
if ($existing) { throw "User already exists." }
# Generate a 16-char secure password
$chars = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789!@#$%'.ToCharArray()
$rng = [System.Security.Cryptography.RandomNumberGenerator]::Create()
$bytes = New-Object byte[] 16
$rng.GetBytes($bytes)
$password = -join ($bytes | ForEach-Object { $chars[$_ % $chars.Length] })Create the user
$params = @{
AccountEnabled = $true
DisplayName = $DisplayName
MailNickname = $MailNickname
UserPrincipalName = $UserPrincipalName
PasswordProfile = @{
ForceChangePasswordNextSignIn = $true
Password = $password
}
}
$newUser = New-MgUser -BodyParameter $paramsAfter creation, hand the credentials to the recipient via your preferred secure channel. The downloadable script below automates the full flow, including optional email delivery.
Next steps