Find Users Whose Password Never Expires in Active Directory
List accounts with "Password never expires" using PowerShell, why they are a risk, service account exceptions, and how to remove the flag.
An account with "Password never expires" (PNE) keeps its password forever, whatever the domain password policy says. It is set for convenience during setup and then forgotten. A password chosen years ago, and possibly leaked since, stays valid.
List PNE accounts
Get-ADUser -Filter 'PasswordNeverExpires -eq $true -and Enabled -eq $true' `
-Properties PasswordNeverExpires, PasswordLastSet, LastLogonDate, Description |
Select-Object SamAccountName, PasswordLastSet, LastLogonDate, Description |
Sort-Object PasswordLastSet
The list starts with the oldest password. Accounts whose PasswordLastSet is years
ago come first.
A shorter way to get the same result:
Search-ADAccount -PasswordNeverExpires -UsersOnly
Why it is a risk
- The old password may have leaked. A password reused and leaked elsewhere keeps working on this account because it never expires.
- The account may be forgotten. An account of a departed employee or an old project that is both enabled and PNE is a door nobody watches.
- Service accounts are targeted. Service accounts whose passwords never change are the most valuable targets in attacks such as Kerberoasting.
What about service accounts?
Some service account passwords cannot be changed without stopping the service, so they get PNE. Better options:
- Group Managed Service Account (gMSA): Active Directory generates the password and rotates it automatically. For services that support it, this is the best way.
- A long random password plus a documented rotation schedule: when gMSA is not possible, use at least 25 characters, keep the password in a vault and change it at least once a year.
Either way, write the owner and purpose in the account's description.
Removing the flag
To remove the flag from accounts that are not exceptions:
Set-ADUser -Identity ahmet.yilmaz -PasswordNeverExpires $false
For a user with a very old password, removing the flag can mean the password expires immediately and must be changed at next sign-in. Tell users before a bulk change, and do it in batches if needed.
In PRESS
The Password Never Expires (PNE) Users report in the PRESS admin panel lists these accounts, and their count appears in the dashboard suggestions. The report can be exported to Excel and PDF.
Evaluate PRESS in your own environment.
Through the live demo you can explore the user portal and the admin panel directly.