• 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:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
Like Loading...

Related

Leave a comment Cancel reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <pre> <q cite=""> <s> <strike> <strong> 

  •  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

Beach BallsSequoia StairwayLittle HavanaBlack Star
More Photos
Back To Top

Website Powered by WordPress.com.

  • Comment
  • Reblog
  • Subscribe Subscribed
    • Unreal Labs
    • Already have a WordPress.com account? Log in now.
    • Unreal Labs
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Copy shortlink
    • Report this content
    • View post in Reader
    • Manage subscriptions
    • Collapse this bar
%d