In PowerShell, the Get-ADUser cmdlet is used with a filter for the PasswordNeverExpires property to list Active Directory (AD) users whose passwords never expire. This is important for security and compliance, as accounts with non-expiring passwords can pose major risks. By identifying them, admins can take the necessary steps to configure password expiration.
While PowerShell helps admins with tasks like these, it requires scripting knowledge, careful filtering, and manual exporting for further analysis. In contrast, ManageEngine ADManager Plus, a web-based AD management and reporting tool, helps you generate this report in a few clicks.
The table below lists the steps to list AD users with passwords that never expire using PowerShell and ADManager Plus.
Prerequisites
Import the AD module (if not done already) using this command:
Import-Module ActiveDirectory
Using the Get-ADUser cmdlet to list users with PasswordNeverExpires property
Run the command below to get all users whose passwords never expire. This outputs a table with user names, their SAM account names, and the relevant attribute.
Get-ADUser -Filter 'PasswordNeverExpires -eq $true' -Properties PasswordNeverExpires |
Select-Object Name, SamAccountName, PasswordNeverExpires
To import users using ADManager Plus:
What's next? Configure password expiration for your users by following these steps.
Get-ADUser -Filter 'PasswordNeverExpires -eq $true' -Properties PasswordNeverExpires |
Select-Object Name, SamAccountName, PasswordNeverExpires |
Export-Csv -Path "C:\ADUsers_PasswordNeverExpires.csv" -NoTypeInformation
Get-ADUser -Identity <username> -Properties PasswordNeverExpires | Select-Object SamAccountName, PasswordNeverExpires
Search-ADAccount -PasswordNeverExpires | Where-Object {$_.Enabled -eq $true} | Select-Object Name, Enabled
The following are essential parameters to perform password expiration tasks in PowerShell:
| Parameter | Description |
|---|---|
| -Filter | Finds users matching password policy conditions. |
| -Properties | Displays extended properties (PasswordNeverExpires). |
| -Identity | Checks a specific user by username or SamAccountName. |
| -Export-Csv | Used to export the report to a CSV file (not a cmdlet parameter, but used in the pipeline). |
| -Path | Output file path for exported report. |
ADManager Plus is a web-based AD and Microsoft Entra ID management and reporting tool that simplifies AD password management and more from a centralized interface:
You can check if a user's password is set to never by expire using the Get-ADUser cmdlet in PowerShell, with a filter for the PasswordNeverExpires property. Script-free tools like ADManager Plus help you identify AD users whose passwords never expire by generating or scheduling reports.
You can set AD users' passwords to never expire using PowerShell and GUI-based tools like Active Directory Users and Computers and ManageEngine ADManager Plus. View the detailed comparison steps here.