How to Get-Aduser password last set with Days since password last set

Anonymous
2024-01-11T08:42:32+00:00

Hi Everyone,

I ask about how to get aduser last password set with "days since password last set"

Below is example when we use ManageEngine AD manager tool, but we need to know how when use powershell script :

Display Name SAM Account Name Password Last Set Days since password last set Password Expiry Date
6D 6d 2023-12-04 09:46:14 38 2024-01-23 09:46:14
A Daffa Ardya E Putra daffa.putra 2023-12-21 08:34:41 21 2024-03-20 08:34:41
A Prasad Babu prasad.babu 2023-12-04 14:43:49 38 2024-01-23 14:43:49
Abdul Azis Ichwan abdul.ichwan 2023-12-13 08:55:15 29 2024-03-12 08:55:15
Abdul Kamal Afkari abdul.afkari 2023-12-06 21:39:20 36 2024-01-25 21:39:20
Abdul Rohman abdul.rohman 2023-12-01 09:34:49 41 2024-02-29 09:34:49
Windows for business | Windows Server | User experience | PowerShell

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question. To protect privacy, user profiles for migrated questions are anonymized.

0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-01-12T05:45:57+00:00

    Hi,

    There is no "days since password last set" attribute however you can use get it like this.

    $user = Get-ADUser -Identity $SAMAccountName -Properties PasswordLastSet
    
    ([datetime]::Now - $user.PasswordLastSet).Days
    
    0 comments No comments