๐ฅ Recipe ยท User & Group Management
Reset a User's Password and Send a Welcome Email with Credentials via Microsoft Graph
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
Context
Why This Matters
Why this recipe matters
Onboarding a new user into Microsoft 365 โ whether for a beta program, a new hire, or a re-activated account โ almost always ends the same way: the admin resets the password, copies it somewhere, and emails the credentials to an external address the user can actually reach (because they can't sign in to their new M365 mailbox yet).
This recipe 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 the gotcha most admins hit on the way: standard password resets often fail for privileged accounts, requiring a fallback via the Authentication Methods API.
When to run it
- Beta program or pilot user onboarding
- New-hire provisioning where the user hasn't received their M365 mailbox yet
- Forgotten-password recovery where the user has no registered MFA methods
- Helpdesk ticket resolution where credentials must be delivered out-of-band
Expected Outcomes
What you'll have when done
- โ The target user account has a new, strong temporary password
- โ
forceChangePasswordNextSignInis set so the user must rotate the password on first login - โ A formatted welcome email is delivered to the user's external/alternate address containing their UPN, temporary password, and login URLs
- โ A clean audit trail in the Entra audit log showing who reset the password and when
- โ A reusable procedure for the next onboarding โ no more manually typing credentials into emails
Risks & Considerations
โ ๏ธ Warnings and gotchas
- Privileged accounts behave differently. If the target user holds a directory role (Global Admin, User Admin, Cloud App Admin, etc.), the standard
PATCH /users/{id}with apasswordProfilewill fail with 403 Insufficient privileges even when you haveUser.ReadWrite.All. You must use the Authentication Methods API and haveUserAuthenticationMethod.ReadWrite.Allplus 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, ensure the message is sent encrypted (e.g., 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 at least 12 characters 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 Entra audit logs; make sure the operation is tied to a ticket or documented business reason.
Required Permissions
| Permission | Why It's Needed |
|---|---|
| User.Read.All | Resolve the target user by display name or UPN |
| User.ReadWrite.All | Reset password via the standard passwordProfile property on the user object |
| UserAuthenticationMethod.ReadWrite.All | Required fallback path for resetting passwords on privileged/admin accounts via the Authentication Methods API |
| Mail.Send | Send the welcome email to the user's external address from the signed-in admin's mailbox |
| Directory.Read.All | Enumerate the target user's directory role memberships to determine whether the privileged reset path is required |
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
For End Users
How an employee would ask Dex for help
Manual walkthrough โ Microsoft 365 Admin Center
Step 1: Reset the password
- Sign in to the at
https://admin.microsoft.com. - Navigate to .
- Search for the target user and click their display name to open the details pane.
- Click Reset password at the top of the pane.
- Choose Let me create the password and enter a strong temporary password (or choose Auto-generate).
- Check Require this user to change their password when they first sign in.
- Click Reset password. Copy the password from the confirmation screen โ it will not be shown again.
Step 2: Send the welcome email
- Open Outlook (web or desktop) signed in as the admin.
- Compose a new message to the user's external address (e.g., their personal or prior-employer email).
- Paste the welcome email template and fill in the UPN and temporary password.
- If available, enable Encrypt (Options โ Encrypt โ Encrypt-Only) to protect the credentials in transit.
- Send.
Privileged accounts โ alternative path
If the user holds an admin role and the reset above is blocked, use:
- Navigate to the โ .
- Click Reset password at the top. You must be signed in with Privileged Authentication Administrator or Global Administrator role.
- Copy the auto-generated password and deliver it via the welcome email.
Microsoft Graph API recipe
1. Resolve the user
GET https://graph.microsoft.com/v1.0/users?$filter=userPrincipalName eq '{upn}'&$select=id,displayName,userPrincipalName,accountEnabledStore the returned id for subsequent calls.
2. (Optional) Check for directory roles
If the user holds a privileged role, you'll need the Authentication Methods API fallback:
GET https://graph.microsoft.com/v1.0/users/{id}/memberOf/microsoft.graph.directoryRole?$select=id,displayName3a. 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/methods/{methodId}/resetPassword
Content-Type: application/json
{
"newPassword": "{temporaryPassword}"
}Where {methodId} is the ID of the user's existing password authentication method, retrieved via 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 walkthrough (Microsoft Graph SDK)
This approach uses the Microsoft.Graph PowerShell module and 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 $profile4. Fallback for privileged users
If step 3 throws 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/methods/$($method.Id)/resetPassword" `
-Body (@{ newPassword = $tempPassword } | ConvertTo-Json)5. Send the welcome email
Send-MgUserMail -UserId (Get-MgContext).Account -BodyParameter $mailPayloadThe downloadable script below wraps all of this with parameters, error handling, and the fallback path.
Next steps