zaro

How to check last password change in Windows server?

Published in Windows Server Security 3 mins read

To check the last password change in Windows Server, the most direct and efficient method involves using PowerShell with the Active Directory module.

How to Check Last Password Change in Windows Server?

The most straightforward way to ascertain the last password change for a user account in a Windows Server environment, particularly when integrated with Active Directory, is by leveraging PowerShell's Get-ADUser cmdlet. This command directly queries the pwdLastSet attribute, providing an accurate timestamp.

1. Using PowerShell (Recommended Method)

PowerShell offers robust capabilities for managing Active Directory user properties, including the pwdLastSet attribute, which stores the timestamp of the last password modification. This method is highly effective for both individual user queries and bulk reporting.

Prerequisites:

Before running PowerShell commands, ensure that the Active Directory PowerShell module is installed on your server or workstation. If not, you can usually add it via the "Add Roles and Features" wizard (Role: Remote Server Administration Tools > Role Administration Tools > AD DS and AD LDS Tools > Active Directory Module for Windows PowerShell).

Steps to Check a Specific User's Last Password Change:

  1. Open PowerShell: Launch PowerShell with administrative privileges on your Windows Server or a domain-joined workstation.

  2. Execute the Command: Type the following command, replacing 'yourusername' with the actual username of the account you want to check:

    Get-ADUser yourusername -Properties pwdlastset | Select-Object Name, pwdlastset
    • For example, to check the user 'john.doe':
      Get-ADUser john.doe -Properties pwdlastset | Select-Object Name, pwdlastset
  3. Interpret the Output:
    The command's output will display the Name of the user and their pwdlastset property, which is a timestamp indicating when their password was last successfully changed. This value is typically stored in UTC (Coordinated Universal Time).

    • Note: The pwdlastset property works best for domain-connected computers and Active Directory user accounts.

Checking Last Password Change for All Users in a Domain:

To get a comprehensive list of all user accounts and their last password change dates across your domain, you can adapt the command:

Get-ADUser -Filter * -Properties Name, SamAccountName, pwdlastset | Select-Object Name, SamAccountName, pwdlastset | Format-Table -AutoSize

This command will retrieve all user accounts (-Filter *) and display their display name, logon name, and the pwdlastset timestamp in an easy-to-read table format.

2. Using Event Viewer (Auditing Purposes)

While not a direct method to query the last password change property, the Windows Event Viewer can be used to audit password change events, which can help verify recent changes or investigate security incidents.

  1. Open Event Viewer: Press Win + R, type eventvwr.msc, and press Enter.
  2. Navigate to Security Logs: In the Event Viewer, go to Windows Logs > Security.
  3. Filter for Password Change Events:
    • Right-click on Security and select Filter Current Log....
    • In the Event IDs field, enter 4723 (for a user attempting to change their password) and 4724 (for a user successfully setting their own password), or 4738 (for a user account being changed, which includes password resets by an administrator).
    • Click OK.
  4. Review Events: Examine the filtered events for specific users to see when their passwords were changed or reset. This method is more useful for auditing and tracking changes after they occur, rather than retrieving the current pwdlastset property.

Summary of Methods

Here's a quick overview of the primary methods for checking last password change:

Method Description Best For
PowerShell Querying the pwdLastSet attribute directly from Active Directory. Quick, accurate retrieval for one or many users.
Event Viewer Reviewing security logs for password change/reset events. Auditing, historical tracking, security investigation.

By utilizing PowerShell's Get-ADUser cmdlet, administrators can efficiently monitor and report on password change compliance within their Windows Server environment.