Skip to content

How to Get List of Users with Password Never Expires using PowerShell?

You can use PowerShell to get a list of Active Directory users with the “Password Never Expires” attribute set to “True” using the following steps:

  1. Open PowerShell on your domain controller or a computer with the Active Directory PowerShell module installed.
  2. Run the following command to import the Active Directory module:
Import-Module ActiveDirectory
  1. Run the following command to retrieve a list of users with the “Password Never Expires” attribute set to “True”:
Get-ADUser -Filter {Enabled -eq $True -and PasswordNeverExpires -eq $True} -Properties Name, SamAccountName, PasswordNeverExpires | Select-Object Name, SamAccountName

This command retrieves all enabled user accounts where the “Password Never Expires” attribute is set to “True” and returns the “Name” and “SamAccountName” attributes in a table format.

You can export this information to a CSV file by appending the following command to the end of the previous command:

active directory auditing solutions
ManageEngine Applications Manager
Export-CSV -Path "C:\Users\username\Documents\password_never_expires.csv" -NoTypeInformation

Replace “C:\Users\username\Documents\password_never_expires.csv” with the path and filename of the CSV file you want to create.

This will create a CSV file with the list of users with the “Password Never Expires” attribute set to “True” in the specified location.