Create a New Entra ID User and Email Temporary Credentials

Prev Next

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.

Why use this workflow

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 workflow covers that exact scenario: 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

  • A new enabled Entra ID user at {user_upn} with display name {display_name}
  • A 16-character cryptographically-random temporary password
  • forceChangePasswordNextSignIn set to true so 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 and considerations

  • 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

PermissionWhy it's needed
User.ReadWrite.AllCreate the new user object and set initial password profile
User.Read.AllCheck whether the target UPN already exists before creating
Directory.ReadWrite.AllRequired for writing directory objects in some tenant configurations
Mail.SendOnly if delivering credentials via Graph sendMail from a service mailbox

Ask Dex

Paste the prompt into a Dex conversation.

Prompt for IT admins

Create a new Entra ID user: display name {display_name}, UPN {user_upn}, no license assigned. Generate a secure temporary password, force change at next sign-in, and email the credentials to {recipient_email}.

Manual steps (admin center)

  1. Sign in to the Microsoft Entra admin center at https://entra.microsoft.com as a User Administrator or Global Administrator.
  2. Go to Identity > Users > All users > + New user > Create new user.
  3. 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
  4. Skip the Properties, Assignments, and Review + create steps for license/group assignment (leave empty for an unlicensed account).
  5. Click Review + create, then Create.
  6. Copy the generated password from the confirmation screen: it will not be shown again.
  7. 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.

Microsoft Graph API

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.

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 (plus Mail.Send if 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 $params

After creation, hand the credentials to the recipient via your preferred secure channel.