How to Get AD Users Password Expiration Date

In this guide, I’ll show you how to get the password expiration date for Active Directory User Accounts.

This is very easy to do.

I will provide a few examples that go over how to get this information for a single user and how to get the expiration date for all AD users.

Check it out.

Method 1: Using Net User command to Display User Expiration Date

This first method uses the net user command that is built into windows. This command is used to add, remove and make changes to user and computer accounts.

To determine when the password will expire for a single account open the command prompt and type the following command:

Net user USERNAME /domain

In the below screenshot is an example for the user mfoster.

In addition to displaying the password expires date it also provides other useful information such as password last set, when the password can be changed, if the account is active and so on.

That is it for method 1.

[fl_builder_insert_layout slug=”ad_sw_ad-admin-bundle_incontent”]

Method 2: Using PowerShell To List All Users Password Expiration Date

To query user information with PowerShell you will need to have the AD module installed. If you have the RSAT tools loaded then you are good to go.

To find the date the password was last set, run this command.

get-aduser -filter * -properties passwordlastset, passwordneverexpires |ft Name, passwordlastset, Passwordneverexpires

In the screenshot below you can see it returns all users, password last set date and if the password never expires.

To display the expiration date rather than the password last set date, use this command.

Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} –Properties "DisplayName", "msDS-UserPasswordExpiryTimeComputed" |
Select-Object -Property "Displayname",@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}

Above command https://blogs.technet.microsoft.com/poshchap/2014/02/21/one-liner-get-a-list-of-ad-users-password-expiry-dates/and source:

To export any of the PowerShell results to a CSV just add | export-csv FILEPATH to the end.

I told you this was going to be easy. The PowerShell commands you can literally copy and past and they should work in your environment.  The Net User command just requires you to enter in an AD user account to query.

You Might Also Like…

Recommended Tool: SolarWinds Server & Application Monitor

This utility was designed to Monitor Active Directory and other critical services like Azure, DNS, and DHCP. It will quickly spot domain controller issues, replication, performance issues with cloud services, failed logon attempts, and much more.

What I like best about this tool is it's easy to use interface and instant alerting features.

Download your 30-day free trial

52 thoughts on “How to Get AD Users Password Expiration Date”

  1. So I have a separate OU users in a different user that I want to see when there password expires.
    Were would I make the change for this with in a domain tree?

    Reply
  2. The second method is more accurate if you have Fine-grained Password Policies enabled in the domain.

    Net Use only shows the result from the Default Domain Policy.

    Reply
  3. Is there a field like Enabled that we can use to filter out this where this isn’t set for the user that shows up “12/31/1600 7:00:00 PM”.

    Reply
    • Yes use the below code to return just the enabled users

      get-aduser -filter {Enabled -eq $TRUE} -properties passwordlastset, passwordneverexpires |ft Name, passwordlastset, Passwordneverexpires

      Reply
  4. Hi, how do I query if the password change was successful through powershell?
    thanks for this site by the way, it helped guide me quite alot! 🙂

    Reply
  5. Something useful from Method 1:

    $m=’Password expires’;($MyExp = net user $env:USERNAME /domain | %{if($_ -match $m){get-date ($_ -replace $m,”).trim()}});rv m;

    Reply
  6. If there are multiple OU’s and you want to find the expiring passwords for a specific OU, how would you do that? I’m guessing with ‘-searhbase’, but not sure how. – Thanks

    Reply
    • Here is an example for a specific user

      get-aduser -Identity Alonso.Hall -properties passwordlastset, passwordneverexpires |ft Name, passwordlastset, Passwordneverexpires

      Reply
    • Use the -server to specify the domain server instance

      Get-ADUser -Filter “Name -eq ‘ChewDavid'” -SearchBase “DC=AppNC” -Properties “mail” -Server lds.Fabrikam.com

      Reply
  7. I seem to be having an issue using the -searchbase in the Method-2 above. I keep getting a message ” A parameter cannot be found that matches parameter name ‘SearchBase’. ” Is this possibly a location issue where I am not putting it in the correct location within the Method-2 command?

    Reply
  8. I am using the following commandlet to get the list of last password set and then using a variable to get the value and add -365 to it, however this variable is not getting populated.
    I can see the commandlet work and output values but the variable I am using $PWdLastSet.passwordlastset is not getting any value, am I doing something wrong ?

    $PWdLastSet = get-aduser -filter * -properties passwordlastset, passwordneverexpires -SearchBase “OU=Service Accounts,OU=SG1,OU=AT,DC=wt,DC=ad,DC=cit,DC=cc” |ft Name, passwordlastset, Passwordneverexpires

    $expiredDate = $PWdLastSet.passwordlastset.addDays(-365)

    Reply
  9. Thanks for sharing this, its helpful.
    Is it possible to trim the expiration date..? Just want the date, without time. if so, can you please help with that..?

    Reply
  10. Thanks for sharing this stuff. I have one question

    The expiry time it shows, in which time zone is it, central time ? or the time zone set on the server ?

    Reply
  11. I’m still having trouble getting it to sort by date. It’ll sort alphabetically when I do a sort-object, but expiry just puts them in a random order each time, even though the command runs. Any suggestions?

    Reply
  12. Is there a way to display the date in chronological order? I’m getting the expiration date report but not in order by date. Thank you in advance.

    Reply
    • Yes. Use the sort-object cmdlet.

      get-aduser -filter * -properties passwordlastset, passwordneverexpires | sort-object passwordlastset

      Reply
  13. Nice, trying to filter on “ExpiryDate” but can’t get that work.
    usecase: I want to generate a file of users which have a password experation 5, 4, 3, 2 or 1 day from now.

    Reply
  14. It’s a nice script, but we have so many users that I like to do the following:

    -Filter to only show users with password expriring within 7 days from today (we have fine-grained password policies)
    -Output as JSON (on console)

    For me, that is quite hard to do, for you guys not I guess, can you show me how ?

    Reply
  15. How is it possible to check expiracy for group of users. So instead of either all or just 1 user – i would like to check like user1, user 2 and user 3 – instead of have check one at a time

    Reply

Leave a Comment