Home > Active Directory, PowerShell > Find password last set/reset time using Powershell

Find password last set/reset time using Powershell

This small piece of code helps you to know when a active directory user has changed his password last time. Use your own inventions to make the output appear the way you want.

$user = “user1″
$searcher=New-Object DirectoryServices.DirectorySearcher
$searcher.Filter=”(&(samaccountname=$user))”
$results=$searcher.findone()
$changedtime  = [datetime]::fromfiletime($results.properties.pwdlastset[0])
write-host -b blue -f red The user, $user has changed password last time at $changedtime

It will be more easy if you have Quest PowerShell Cmdlets for active roles installed in your PC. Download it from Quest site and install on your machine and execute the below oneliner in Quest powershell window.

Get-QADUser user1 | ft displayname, PasswordLastSet

Happy Learning..,
Sitaram Pamarthi

  1. PSLover
    August 31, 2010 at 3:39 pm | #1

    Thank you so much for providing this. It worked flawssly the first time, My boss could not logging to the computer and i had to find out whether the password had been changed or not recently, so i was short on time. Best regards

  2. August 31, 2010 at 6:25 pm | #2

    Good to hear that it helped you.

  3. November 7, 2011 at 11:39 pm | #3

    Awesome. Works perfect from my XP workstation.

    • Sitaram Pamarthi
      November 9, 2011 at 1:17 pm | #4

      Thanks for sharing the feedback

  1. No trackbacks yet.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>