fbpx

Get Active Directory Users Password Expiration Date

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 Active Directory users.

Method 1: Using CMD

This first method uses the net user command that is built into CMD in 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

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

netuser

Method 2: Using PowerShell

PowerShell is a much more powerful tool than the Command Prompt. It is also intended to replace the Command Prompt, as it delivers more power and control over the Windows operating system.
To query user information with PowerShell you will need to have the AD module installed. If you have the RSAT tools loaded then there is nothing else to do.
To find the date when the password was last set for all users, run this command:

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

powershell password last set

If you wan’t to view 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”)}}

powershell Expiry Date

If you are using powershell and wan’t to export these results to a csv file, just add | export-csv c:\path to file in the end of command.

Like This? Share IT:

Leave Comment

Adresa ta de email nu va fi publicată. Câmpurile obligatorii sunt marcate cu *