• Home
Unreal Labs

Unreal Labs

Always learning

Powershell – Checking a users last password reset

Aaron · August 12, 2023 · Microsoft, Scripting, Uncategorized · Active Directory, AD password reset, Automation, checking password changes, how to check if a user changed their password, how to check if a user has change their password, how to use powershell to check a users password change, IT Admin, Last Login, password reset times, powershell, powershell scripting, simple powershell checking users password, Techtips, User management, Wordpressit · No Comments

Let’s query Active Directory using PowerShell to determine the last time a user has reset or changed their password. I will use the ‘Get-ADUser’ cmdlet to retrieve user properties and the ‘Get-ADUserResultantPasswordPolicy’ for password last set information. If have documented the script you will find it below.

# Ensure ActiveDirectory module is imported
Import-Module ActiveDirectory

# Define the user you want to check
$user = "username" # replace 'username' with the actual username

# Retrieve user info
$userInfo = Get-ADUser -Identity $user -Properties "PasswordLastSet", "LastLogon", "LastLogonTimestamp"

# Convert the LastLogonTimestamp (which is more reliable) to datetime
$lastLogonDate = [DateTime]::FromFileTime($userInfo.LastLogonTimestamp)

# Display information
Write-Output "User: $($userInfo.SamAccountName)"
Write-Output "Password Last Set: $($userInfo.PasswordLastSet)"
Write-Output "Last Login Time: $lastLogonDate"

Below you will find an example output, I hope this helps and feel free to add, export, or change this as needed.

User: username
Password Last Set: 05/02/2023 16:04:44
Last Login Time: 05/02/2023 16:16:10

Share this:

  • Share on X (Opens in new window) X
  • Share on Facebook (Opens in new window) Facebook
Like Loading...

Related

Leave a Reply Cancel reply

Name and email address are required. Your email address will not be published.

  •  Setting up SFTP on Ubuntu Linux
  • Configuring DHCP on a Cisco Switch 

Categories

Topics

Cisco CMD Fortinet Interwebs linux mac Microsoft robocopy Scripting ShoreTel/Mitel Study Guide Uncategorized VoIP Wazuh Wireshark

Archives

Enter your email address to follow this blog and receive notifications of new posts by email.

Flickr Photos

Snowy Trees - LaplandDiel 02Afterglow (Explore 01.12.2026)The Measuring Tree
More Photos
Back To Top

Website Powered by WordPress.com.

  • Comment
  • Reblog
  • Subscribe Subscribed
    Unreal Labs

    Have a WordPress.com account? Log in now.

  • Unreal Labs
    Copy shortlinkView post in Reader
    Manage subscriptionsSign upLog in
    Report this content
    Collapse this bar
%d