Reset a User's Password and Send a Welcome Email with Credentials via Microsoft Graph

Prev Next

Generate a secure temporary password, reset an M365 user account, and deliver credentials to an alternate email address in one workflow.

Complexity: Intermediate. Impact: user-onboarding + credential-management + beta-program + helpdesk-automation + admin-account-handling.

Why use this workflow

Onboarding a new user into Microsoft 365, whether for a beta program, a new hire, or a re-activated account, often ends the same way: the admin resets the password, copies it somewhere, and emails the credentials to an external address the user can reach, because they cannot sign in to their new Microsoft 365 mailbox yet.

This workflow covers the full loop: generate a strong temporary password, apply it to the user's account, force a password change on next sign-in, and send a formatted welcome email to the user's personal or corporate email. It also documents a common gotcha: standard password resets often fail for privileged accounts, which requires a fallback through the Authentication Methods API.

When to run it

  • Beta program or pilot user onboarding
  • New-hire provisioning where the user has not received their Microsoft 365 mailbox yet
  • Forgotten-password recovery where the user has no registered MFA methods
  • Help desk ticket resolution where credentials must be delivered out-of-band

Expected outcomes

  • The target user account has a new, strong temporary password
  • forceChangePasswordNextSignIn is set so that the user must rotate the password on first sign-in
  • A formatted welcome email is delivered to the user's external or alternate address and contains their UPN, temporary password, and sign-in URL
  • A clean audit trail in the Entra audit log shows who reset the password and when
  • A reusable procedure for the next onboarding, so that you no longer type credentials into emails by hand

Risks and considerations

  • Privileged accounts behave differently. If the target user holds a directory role (Global Administrator, User Administrator, Cloud Application Administrator, and so on), the standard PATCH /users/{id} with a passwordProfile can fail with 403 Insufficient privileges even when you have User.ReadWrite.All. Use the Authentication Methods API, and have UserAuthenticationMethod.ReadWrite.All plus the Privileged Authentication Administrator role.
  • Credentials in plain-text email are risky. Prefer a Temporary Access Pass (TAP) or a password reset link where possible. If you must email a password, send the message encrypted (for example, with Microsoft Purview Message Encryption) or use a one-time-view service.
  • Always set forceChangePasswordNextSignIn: true. Never leave a temporary password in place as the user's permanent credential.
  • Password complexity. Generate a strong password that meets your tenant password policy, with mixed case, digits, and symbols. Avoid ambiguous characters (0/O, 1/l/I).
  • MFA still applies. Resetting the password does not bypass Conditional Access or MFA. If the user has no registered methods, they may be blocked at sign-in. Issue a TAP instead.
  • Audit compliance. Every password reset is logged in the Entra audit logs. Make sure the operation is tied to a ticket or documented business reason.

Required permissions

PermissionWhy it's needed
User.Read.AllResolve the target user by display name or UPN
User.ReadWrite.AllReset the password through the standard passwordProfile property on the user object
UserAuthenticationMethod.ReadWrite.AllRequired fallback path for resetting passwords on privileged and admin accounts through the Authentication Methods API
Mail.SendSend the welcome email to the user's external address from the signed-in admin's mailbox
Directory.Read.AllEnumerate the target user's directory role memberships to determine whether the privileged reset path is required

Ask Dex

Paste the prompt into a Dex conversation.

Prompt for IT admins

Reset the password for {user} and send a welcome email to their external address {external_email} with the new temporary credentials, login URL, and instructions to change the password on first sign-in. Force password change on next sign-in.

How an end user can ask Dex

Please reset my Microsoft 365 password and send the new one to my personal email so I can get back in.

Manual steps (admin center)

Step 1: Reset the password

  1. Sign in to the Microsoft 365 admin center.
  2. Go to Users > Active users.
  3. Search for the target user and select their display name to open the details pane.
  4. Select Reset password at the top of the pane.
  5. Choose Let me create the password and enter a strong temporary password (or choose Auto-generate).
  6. Select Require this user to change their password when they first sign in.
  7. Select Reset password. Copy the password from the confirmation screen. It is not shown again.

Step 2: Send the welcome email

  1. Open Outlook (web or desktop) signed in as the admin.
  2. Compose a new message to the user's external address (for example, their personal or prior-employer email).
  3. Paste your welcome email template and fill in the UPN and temporary password.
  4. If available, turn on encryption (Options > Encrypt > Encrypt-Only) to protect the credentials in transit.
  5. Send the message.

Privileged accounts: alternative path

If the user holds an admin role and the reset above is blocked, use this path:

  1. Go to the Microsoft Entra admin center > Users > select the user > Authentication methods.
  2. Select Reset password at the top. You must be signed in with the Privileged Authentication Administrator or Global Administrator role.
  3. Copy the auto-generated password and deliver it through the welcome email.

Microsoft Graph API

1. Resolve the user

GET https://graph.microsoft.com/v1.0/users?$filter=userPrincipalName eq '{upn}'&$select=id,displayName,userPrincipalName,accountEnabled

Store the returned id for subsequent calls.

2. (Optional) Check for directory roles

If the user holds a privileged role, you need the Authentication Methods API fallback:

GET https://graph.microsoft.com/v1.0/users/{id}/memberOf/microsoft.graph.directoryRole?$select=id,displayName

3a. Standard password reset (non-privileged users)

PATCH https://graph.microsoft.com/v1.0/users/{id}
Content-Type: application/json

{
  "passwordProfile": {
    "forceChangePasswordNextSignIn": true,
    "password": "{temporaryPassword}"
  }
}

Expected response: 204 No Content.

3b. Privileged-account fallback: Authentication Methods API

If the PATCH returns 403 Insufficient privileges, the user is likely an admin. Use:

POST https://graph.microsoft.com/v1.0/users/{id}/authentication/passwordMethods/{methodId}/resetPassword
Content-Type: application/json

{
  "newPassword": "{temporaryPassword}"
}

Where {methodId} is the ID of the user's existing password authentication method, retrieved with GET /users/{id}/authentication/passwordMethods. The caller must have UserAuthenticationMethod.ReadWrite.All and the Privileged Authentication Administrator role.

4. Send the welcome email

POST https://graph.microsoft.com/v1.0/me/sendMail
Content-Type: application/json

{
  "message": {
    "subject": "Welcome to {ProgramName}",
    "body": {
      "contentType": "Text",
      "content": "Hi {FirstName},\n\nYour account is ready.\n\nUsername: {upn}\nTemporary Password: {temporaryPassword}\n\nLogin: https://login.microsoftonline.com/\n\nPlease change your password on first sign-in."
    },
    "toRecipients": [
      { "emailAddress": { "address": "{externalEmail}" } }
    ]
  },
  "saveToSentItems": true
}

Expected response: 202 Accepted.

PowerShell

Use the Microsoft.Graph PowerShell module. This approach works for both standard and privileged users.

1. Install and connect

Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "User.ReadWrite.All","UserAuthenticationMethod.ReadWrite.All","Mail.Send","Directory.Read.All"

2. Generate a strong temporary password

Add-Type -AssemblyName System.Web
$tempPassword = [System.Web.Security.Membership]::GeneratePassword(14, 3)

3. Resolve the user and attempt the standard reset

$user = Get-MgUser -UserId $Upn
$profile = @{ Password = $tempPassword; ForceChangePasswordNextSignIn = $true }
Update-MgUser -UserId $user.Id -PasswordProfile $profile

4. Fallback for privileged users

If step 3 returns a 403, call the Authentication Methods endpoint:

$method = Get-MgUserAuthenticationPasswordMethod -UserId $user.Id
Invoke-MgGraphRequest -Method POST `
  -Uri "https://graph.microsoft.com/v1.0/users/$($user.Id)/authentication/passwordMethods/$($method.Id)/resetPassword" `
  -Body (@{ newPassword = $tempPassword } | ConvertTo-Json)

5. Send the welcome email

Send-MgUserMail -UserId (Get-MgContext).Account -BodyParameter $mailPayload