Check When a Microsoft 365 User's Password Expires

Prev Next

Determine the password expiration date for any Microsoft 365 user and proactively notify them before lockout.

Complexity: Beginner. Impact: user-support + security + password-policy + entra-id + read-only.

Why use this workflow

End users frequently ask IT when they need to change their password to avoid being locked out. In Microsoft 365, password expiration behavior depends on the tenant's password policy and per-user settings. Some users may have PasswordNeverExpires enabled, while others inherit the tenant default.

This workflow shows how to calculate a user's password expiration date by combining the last password change timestamp with the tenant password validity period. It is useful for:

  • Responding to individual user questions about upcoming expiration
  • Proactively warning users before their password expires
  • Auditing accounts whose passwords never expire (a security concern)
  • Troubleshooting authentication failures suspected to be caused by expired credentials

Expected outcomes

  • The exact date and time of the user's last password change
  • The tenant's password validity period (in days)
  • A calculated password expiration date for the user
  • Confirmation of whether the user's password is set to never expire
  • The number of days remaining until expiration

Risks and considerations

  • Check your organization's policy first. Microsoft's guidance favors disabling password expiration in favor of MFA and risk-based Conditional Access. Verify your organization's policy before you recommend any expiration scheme.
  • The lastPasswordChangeDateTime property updates only when the password changes. It may not reflect forced resets in all cases. Validate against sign-in logs if precision matters.
  • Per-user PasswordNeverExpires overrides the tenant policy. A user with this flag set never receives an expiration warning even if the tenant policy enforces rotation.
  • The tenant-wide password validity period is stored on the domain object (passwordValidityPeriodInDays), not the user. A value of 2147483647 (Int32.MaxValue) indicates "never expires" at the tenant level.
  • Do not communicate expected expiration dates to users as a guarantee: admins or policy changes can force a reset at any time.

Required permissions

PermissionWhy it's needed
User.Read.AllRead user properties including lastPasswordChangeDateTime and passwordPolicies
Domain.Read.AllRead the tenant's password validity period from the default domain
Directory.Read.AllAlternative broader scope if User.Read.All and Domain.Read.All are not available

Ask Dex

Paste the prompt into a Dex conversation.

Prompt for IT admins

Check when {user}'s Microsoft 365 password expires. Report the last password change date, the tenant password validity policy, the calculated expiration date, and days remaining, and flag if the account is set to never expire.

How an end user can ask Dex

When do I need to change my Microsoft 365 password? I don't want to get locked out.

Manual steps (admin center)

The admin center does not show an exact expiration date, but you can find the last password change and the tenant policy and calculate it yourself.

Step 1: Find the user's last password change

  1. Sign in to the Microsoft 365 admin center as a Global Administrator or User Administrator.
  2. Go to Users > Active users.
  3. Select the display name of the target user to open their profile pane.
  4. Select the Account tab.
  5. Note the value under Password last changed.

Step 2: Check the tenant password policy

  1. In the admin center, go to Settings > Org settings > Security & privacy.
  2. Select Password expiration policy.
  3. If "Set user passwords to expire after a number of days" is cleared, passwords never expire at the tenant level. Stop here.
  4. If it is selected, note the value in Days before passwords expire.

Step 3: Calculate expiration

Expiration date = Password last changed + Days before passwords expire.

Step 4: Verify the user is not exempt

  1. Back on the user's profile, check the Account tab for "Password never expires". If it appears, the user is exempt regardless of tenant policy.

Microsoft Graph API

Combine two Graph calls: one to read the user's last password change and policy flags, and one to read the tenant-wide validity period from the default domain.

1. Get the user's password metadata

GET https://graph.microsoft.com/v1.0/users/{userPrincipalName}?$select=id,userPrincipalName,lastPasswordChangeDateTime,passwordPolicies

Example response:

{
  "id": "a1b2c3d4-...",
  "userPrincipalName": "alice@contoso.com",
  "lastPasswordChangeDateTime": "2024-08-15T14:22:10Z",
  "passwordPolicies": "None"
}

If passwordPolicies contains DisablePasswordExpiration, the user's password never expires.

2. Get the tenant password validity period

GET https://graph.microsoft.com/v1.0/domains?$select=id,isDefault,passwordValidityPeriodInDays,passwordNotificationWindowInDays

Example response (default domain object):

{
  "id": "contoso.onmicrosoft.com",
  "isDefault": true,
  "passwordValidityPeriodInDays": 90,
  "passwordNotificationWindowInDays": 14
}

A value of 2147483647 means passwords never expire at the tenant level.

3. Calculate

expirationDateTime = lastPasswordChangeDateTime + passwordValidityPeriodInDays

Required headers

  • Authorization: Bearer {access_token}
  • Accept: application/json

PowerShell

The Microsoft Graph PowerShell SDK makes this straightforward. Install it once with Install-Module Microsoft.Graph -Scope CurrentUser.

Connect

Connect-MgGraph -Scopes "User.Read.All","Domain.Read.All"

Read user properties

$user = Get-MgUser -UserId "alice@contoso.com" -Property Id,UserPrincipalName,LastPasswordChangeDateTime,PasswordPolicies
$user | Select-Object UserPrincipalName,LastPasswordChangeDateTime,PasswordPolicies

Read tenant password policy

$domain = Get-MgDomain | Where-Object IsDefault -eq $true
$validityDays = $domain.PasswordValidityPeriodInDays

Calculate expiration

if ($user.PasswordPolicies -match "DisablePasswordExpiration") {
    Write-Host "Password never expires for this user."
} elseif ($validityDays -eq 2147483647) {
    Write-Host "Tenant policy: passwords never expire."
} else {
    $expires = $user.LastPasswordChangeDateTime.AddDays($validityDays)
    $daysLeft = ($expires - (Get-Date)).Days
    Write-Host "Expires on $expires ($daysLeft days remaining)"
}