Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Azure / How to Reset User Password in Azure Active Directory (Microsoft 365)

June 8, 2023 AzureMicrosoft 365PowerShell

How to Reset User Password in Azure Active Directory (Microsoft 365)

If an Azure Active Directory user forgets his password, an Azure (Microsoft 365) tenant administrator can reset it in several ways: using the Azure Portal, through PowerShell, or by enabling the self-service password reset (SSPR) feature.

Contents:
  • Reset User’s Password in Azure Portal
  • Resetting Azure AD User Password with PowerShell

To reset a user’s password, your account must have one of the following built-in Azure: User Administrator or Password Administrator.

Reset User’s Password in Azure Portal

The easiest way to reset a user password in Azure is to use the Azure Portal web interface (or Microsoft 365 Admin Center):

  1. Sign in to https://portal.azure.com/ and go to Azure Active Directory -> Users;
  2. Select a user and click Reset Password; azure ad portal - reset user password
  3. You will receive a notification that a temporary password will be assigned to the user:
    The user '[email protected]' will be assigned a temporary password that must be changed on the next sign in. To display the temporary password, click 'Reset password'.

    Click Reset Password.

  4. Azure will generate a new temporary password for the user and show it on the screen; temporapy password for Azure AD user
  5. Tell the new password to the user, and the next time they sign in to any Microsoft 365 app using Modern Authentication, they will be prompted to change the password;
    Your need to update your password because this is the first rime you are signing in, or because your password has expired.

    form to change expired password in azure ad

  6. You can make sure that the user has authenticated successfully using the Azure sign-in logs.

Here are some important things to keep in mind:

  • A temporary password never expires.
  • If your on-premises Active Directory is synchronized with Azure through the Azure AD Connector, the Password Writeback feature must be enabled in the Connector settings in order to reset the ADDS user’s password from the cloud.

You can enable self-service password reset (SSPR) on your Azure tenant. You can enable SSPR for a group of users or all AAD users in Azure Active Directory -> Password reset -> Properties.

enable enable self-service password reset in Azure

To reset their passwords, users can use allowed authentication methods. In addition to standard MFA methods, they can use security questions and office phone calls. You can use one or two authentication methods.

configure authentication methods for azure enable self-service password reset

Resetting Azure AD User Password with PowerShell

When you reset a user’s password via the Azure Portal, a new temporary password is automatically generated. However, you can set a new user password manually using PowerShell.

You can also set a new user password manually through the Microsoft 365 Admin Center.

You can use the Azure AD module to reset a user’s password. Connect to your Azure tenant:

Connect-AzureAD

Set a new password and convert it to SecureString (see the article on how to use passwords in PowerShell scripts):

$newPass = ConvertTo-SecureString 'Str0ngNewPa$$1' -AsPlainText –Force

You can use PowerShell to generate a strong random password:

Add-Type -AssemblyName System.Web
$genpass=[System.Web.Security.Membership]::GeneratePassword(9,2)
$newPass = ConvertTo-SecureString $genpass -AsPlainText –Force

Get the Object ID of the user for which you want to change the password using its UserPrincipalName:

$userObjectId=(Get-AzureADUser -filter "userPrincipalName eq '[email protected]'").ObjectID

Apply the new password to the Azure user by ObjectID:

Set-AzureADUserPassword -ObjectId $userObjectId -Password $newPass

Set-AzureADUserPassword powershell

If you want a user to change the password at the next sign-in, add the -ForceChangePasswordNextLogin $true option.

You won’t be able to view the date and time when the user changed the password using the Azure AD PowerShell module. You can get this information using Microsoft Graph API or the legacy MSOnline module.

If you have the MSOnline PowerShell module installed, connect to your tenant:

Connect-MsolService

Display the LastPasswordChangeTimeStamp value:

Get-MsolUser -UserPrincipalName '[email protected]'| Select DisplayName,UserPrincipalName,LastPasswordChangeTimeStamp

Get-MsolUser LastPasswordChangeTimeStamp

If the password expiration option is enabled in the Azure AD password policy, you can get the date when a user password expires using PowerShell:

$user=Get-MsolUser -UserPrincipalName '[email protected]'
$User.LastPasswordChangeTimestamp.AddDays($PasswordPolicy.ValidityPeriod)

In on-premises Active Directory Domain Services, you can get the password expiration date for a domain user from the msDS-UserPasswordExpiryTimeComputed constructed attribute.

Or you can access the Microsoft Graph API from PowerShell to get the date and time the user’s password was changed and the user creation data in Azure:

$ApplicationID = "your-app-ID"
$TenatDomainName = "your-tenant-ID"
$AccessSecret = "your-app-secret"
$Body = @{
Grant_Type    = "client_credentials"
Scope         = "https://graph.microsoft.com/.default"
client_Id     = $ApplicationID
Client_Secret = $AccessSecret
}
$ConnectGraph = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$TenatDomainName/oauth2/v2.0/token" -Method POST -Body $Body
$token = $ConnectGraph.access_token
$GrapUserUrl = 'https://graph.microsoft.com/v1.0/users?$select= userprincipalname,accountenabled,signInActivity,createdDateTime,lastPasswordChangeDateTime'
$users=(Invoke-RestMethod -Headers @{Authorization = "Bearer $($token)"} -Uri $GrapUserUrl -Method Get).value
$users | where userprincipalname –eq '[email protected]' | select userprincipalname,accountenabled,createdDateTime,lastPasswordChangeDateTime

Get Azure AD user LastPasswordChangeDateTime using PowerShell and Microsoft Graph API

Using Microsoft Graph API and the POST method, you can even reset a user password. Use the POST request below:

POST https://graph.microsoft.com/v1.0/me/changePassword
Content-Type: application/json
  {
     "currentPassword": "OldPass123!",
     "newPassword": "NewP@ss2!"
   }
Learn how to reset user passwords in the local Active Directory in this article.

1 comment
0
Facebook Twitter Google + Pinterest
previous post
How to Delete or Rename Default Mailbox Database in Exchange Server
next post
Install Active Directory Users and Computers (ADUC) Snap-in on Windows 10/11

Related Reading

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

October 15, 2023

How to Query and Change Teams User Presence...

October 8, 2023

Installing Language Pack in Windows 10/11 with PowerShell

September 15, 2023

1 comment

tiesj May 31, 2022 - 9:51 am

hello,

and how do we get in msgraph the next date of the expiration.. i mean lastpasswordchangetime +30 days .eg

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Checking User Sign-in Logs in Azure AD (Microsoft 365)
  • Whitelist Domains and Email Addresses on Exchange Server and Microsoft 365
  • Enabling Modern or Basic Authentication for Microsoft 365
  • Using Microsoft Graph API to Access Azure via PowerShell
  • Configuring Azure AD Password Policy
  • Enable or Disable MFA for Users in Azure/Microsoft 365
  • IdFix: Preparing On-Prem Active Directory Sync with Azure
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top