🎉 Our Microsoft 365 Reporting & Management Tool is available in Marketplace 🚀
Active Directory

How To Get All Users with Password Never Expires in Active Directory

Password-based attacks are still a favourite method for attackers, making the management of non-expiring credentials more important than ever. Although enabling “Password Never Expires” may seem convenient for some users, it can also make those accounts easier targets for brute-force and credential-stuffing attacks. Therefore, this guide explains how to identify all Active Directory users with passwords set to never expire, enabling you to strengthen account security.

Microsoft 365 tools

Track Users with Password Never Expires Using ADUC

Active Directory Permission Required
Accounts Operator Least Privilege
Administrators Most Privilege
  • Open the Active Directory Users and Computers console, then right-click Saved Queries in the left pane and select New » Query.
  • Enter the name and an optional description. Ensure the Include subcontainers checkbox is selected to include all users under subcontainers, then click Define Query.
  • In the Find dropdown, choose Custom Search, select the Advanced tab, and enter the following LDAP query.
    (userAccountControl:1.2.840.113556.1.4.803:=65536)
  • Click OK to save the query, then click OK again to close the configuration window.
Track Users with Password Never Expires Using ADUC
  • Note: You can also view users with passwords set to never expire by using the same LDAP query in Active Directory Administrative Center (ADAC) » Global Search » Convert to LDAP option. However, ADAC does not provide options to add custom columns or export the results, whereas ADUC allows both.

List Users With Password Never Expires in AD Using PowerShell

Active Directory Permission Required
Accounts Operator Least Privilege
Administrators Most Privilege
  • Import the Active Directory module using the cmdlet below.
  • Windows PowerShell Windows PowerShell
     Import-Module ActiveDirectory
  • Then, execute the following cmdlet to list all users with the password never expire setting enabled in your Active Directory.
  • Windows PowerShell Windows PowerShell
     Get-ADUser -Filter * -Properties PasswordNeverExpires, PasswordLastSet, LastLogonDate | 
    Where-Object { $_.PasswordNeverExpires -eq $true } | 
    Select-Object Name, SamAccountName, UserPrincipalName, Enabled, PasswordNeverExpires, PasswordLastSet, LastLogonDate | 
    Format-Table –AutoSize
  • This cmdlet fetches all users with passwords set to never expire, along with their name, SAM account name, UPN, account status, password last set, and last logon date & time.
List Users With Password Never Expires in AD Using PowerShell

Get AD Users with Never-Expiring Passwords Using PowerShell Script

Active Directory Permission Required
Account Operators Least Privilege
Administrators Most Privilege
  • The cmdlet above is ideal for quickly identifying users whose passwords never expire. However, it isn't well suited for routine audits or scheduled reporting.
  • To simplify the process, we've built a PowerShell script that exports all users with passwords set to never expire, along with the required attributes for reporting.
  • Download and run the script as follows to retrieve all Active Directory accounts with passwords set to never expire in a domain.
  • Windows PowerShell Windows PowerShell
     .\ADUsersPasswordExpiryReport.ps1 -PasswordNeverExpiresOnly
  • The report exports all users whose passwords are configured to never expire, along with details like password last set date, password age, last logon time, etc.
Get AD Users with Never-Expiring Passwords Using PowerShell Script
ADUsersPasswordExpiryReport.ps1

Improve Active Directory Password Hygiene with Complete Visibility

AdminDroid’s Active Directory reporting tool gives admins gain detailed insights into users with password expiry, accounts with password not required, expired passwords, and more. These insights help admins easily monitor password-related risks and prevent account compromise.

Spot Users Blocked from Changing Passwords to Reduce Access Interruptions

Locate users who cannot change their passwords and ensure their passwords are updated before expiry date to prevent account lockouts.

Find User with Old Passwords to Mitigate the Risk of Password Theft

Locate users with old password that increase the risk of account compromise, as these credentials are more likely to be exposed, reused, or guessed.

Notify Users to Renew their Never Expiring Password

Use the never-expiring password change reminder agent to remind users to rotate their credentials on schedule and reduce stale-password risks.

Get a Complete Overview of Active Directory Passwords in a Single Dashboard

Explore the Active Directory password dashboard for a comprehensive view of password-related details, including expiry status, current password state and more.

Track Password Policy Changes to Avoid Password Renewal Challenges

Review password policy changes in Active Directory to identify misconfiguration or conflicts that could disrupt password resets or scheduled rotations.

Monitor Account with No Password Required to prevent Unauthorized Access

Inspect accounts with no password required and enforce password creation to prevent any unauthenticated access to the domain.

Overall, AdminDroid Active Directory management tool provides a complete control over user account options in Active Directory. It also equips you with management actions such as resetting passwords, configuring logon hours, assigning group managers, and more to streamline administration and reduce operational overhead.

Explore a full range of reporting options

Important tips

Use smart card or certificate based authentication instead of relying solely on passwords to protect high-privileged admin accounts.

Restrict the 'Password Never Expires' setting to a controlled allow-list of essential service or application accounts, and keep a controlled allow-list to prevent its misuse.

Utilize Managed Service Accounts (MSA) instead of user accounts for automation and scheduled tasks to enforce automatic rotation of strong 240-byte passwords every 30 days.

Common Errors and Resolution Steps

The following are possible errors and troubleshooting hints when retrieving users with never expire password in Active Directory.

Error You have selected ‘Password never expires’. The user will not be required to change the password at next logon.

This error occurs when User must change password at next logon option is selected, when the Password never expires option is already in use.

Fix To resolve this error, select one option either User must change password at next logon or Password Never expires while changing the user account settings.

Error Set-ADDefaultDomainPasswordPolicy : A parameter is incorrect.

This error occurs when the password history count is set beyond its maximum allowed range while configuring the default domain password policy using PowerShell.

Fix To fix this error, make sure to use a value between 1 and 24 for the -PasswordHistoryCount parameter while configuring the default domain password policy using the PowerShell cmdlet below.
Set-ADDefaultDomainPasswordPolicy -Identity "<DomainName>" -PasswordHistoryCount "<PasswordReuseCount>"

Error Set-ADUser : Cannot find an object with identity: '<Identity>' under: '<DomainName>'.

This error appears when the -Identity value does not match any existing user in Active Directory.

Fix Replace <Identity> with the user’s unique identifiers like distinguished name/object GUID/object SID/SAM account name and run the cmdlet below.
Set-ADUser -Identity "<Identity>" -PasswordNeverExpires $False

Error Set-ADDefaultDomainPasswordPolicy : Insufficient access rights to perform the operation.

This error appears when your account lacks the necessary permissions to configure the default domain password policy in Active Directory.

Fix To troubleshoot this error, ensure your account is assigned the appropriate rights, such as membership in Domain Admins or Enterprise Admins.

1. How to set passwords to never expire for users in Active Directory?

While Active Directory allows passwords to be set to never expire, this configuration should be avoided for standard user accounts due to the security risks it introduces. It is intended primarily for service accounts and select system-level accounts to support essential operations.

When this setting is legitimately required, you can follow the steps below to enable password never expires for a user.

Set password never expire for AD users using ADUC

  • Open Server Manager and click on Tools » Active Directory Users and Computers.
  • Navigate to the relevant OU or container.
  • Double-click the target user account and go to the Account tab.
  • Select the Password never expires checkbox, then click Apply and OK to save the changes.
set-password-never-expire-in-aduc

Enable password never expire for users using PowerShell

To configure a user account with a non-expiring password, use the cmdlet below, substituting <Identity> with any of these attributes: Distinguished Name, Object GUID, Security Identifier (SID), or SAM account name.

Set-ADUser -Identity "<Identity>" -PasswordNeverExpires $true

Easily assign users with the password never expires in just a few clicks!

  • With AdminDroid, you can directly enable “Password Never Expires” for a user using the Update User Properties management action.
  • In the Update User Properties fly-out pane, select the desired user. Then, choose Password Never Expires from the Select Property drop-down and set it to Yes.
  • Then, click Execute to apply the changes.
set-never-expiring-password-in-droid

2. How to prevent password reuse in Active Directory?

Users often reuse their previous passwords when updating their credentials in Active Directory. This weakens security and increases the risk of compromise.

To prevent this, admins can enforce password history policies that remember a specified number of previous passwords and block their reuse. This ensures that users create a unique password whenever they change it.

Configure enforce password history policy in Active Directory

  • In the Group Policy Management Console (GPMC), expand the domain, right-click on Default Domain Policy and select Edit.
  • Navigate to Computer Configuration » Policies » Windows Settings » Security Settings » Account Policies » Password Policy.
  • Double-click Enforce password history, and in the Security Policy Setting tab, select the Define this policy setting checkbox.
  • Set a value between 1 and 24 to specify how many past passwords users are not allowed to reuse.
enforce-password-history-in-gpo

Set password history policy in Active Directory Using PowerShell

Rather than navigating through GPMC, you can simply run the cmdlet below to change the default domain policy and specify how many previous passwords the domain should remember.

Set-ADDefaultDomainPasswordPolicy -Identity "<DomainName>" -PasswordHistoryCount "<PasswordReuseCount>"

Note: Replace <DomainName> with the name of your domain and <PasswordReuseCount> with number of passwords to be remembered.

3. How to disable never expire password for users in the Active Directory?

For user accounts, setting the password to never expire creates a security vulnerability, making them valuable targets for lateral movement after a compromise. While this setting is essential for service accounts to perform necessary operations, it must be disabled for all user accounts to avoid persistent access by attacker. Therefore, disabling "password never expires" option for users will improve their overall account protection.

Therefore, disabling "password never expires" option for users will improve their overall account protection.

Disable password never expire for a user in Active Directory

  • In the ADUC console, browse through the relevant containers or OUs to locate the desired user account.
  • Select the user and right-click on the user account and click on Properties.
  • Navigate to the Account tab and click on Password never expires option in the Account options.
  • If the option is enabled uncheck the Password never expires checkbox and Click on Apply and select OK.
disable-never-expire-option-for-user-in-ad

Bulk remove password never expire for users using PowerShell

Manually going through each user account to disable the “password never expires” option is a tedious and time-consuming task. This is why PowerShell is used to efficiently disable the setting for multiple users at once.

  • To proceed, prepare a CSV or TXT file containing a unique identifiers like distinguished name/object GUID/object SID/SAM account name of each user as shown here.
  • Then, replace the <FilePath> in the cmdlet below and execute it to disable never expire password for the list of target users.
unique-identifiers-users-list
Import-Csv "<FilePath>" -header ‘Identity’ | ForEach-Object { 
$User = Get-ADUser -Identity $_.Identity -Properties PasswordNeverExpires, Enabled 
     if ($User.PasswordNeverExpires -and $User.Enabled) { 
         Set-ADUser -Identity $_.Identity -PasswordNeverExpires $false 
         Write-Host "Password never expire is removed for $($_.Identity)" 
     } 
     else { 
         Write-Host "Password never expire is already disabled for $($_.Identity)" 
    } 
}
bulk-remove-never-expire-password-in-ad

Kickstart Your Journey With
AdminDroid

Your Microsoft 365 Companion with Enormous Reporting Capabilities

Download Now
User Help Manuals Compliance Docs Customer Stories