Powershell - Find all users with password never expires

Solution 1:

I use the below to and it works.

get-aduser -filter * -properties Name, PasswordNeverExpires | where { $_.passwordNeverExpires -eq "true" } | where {$_.enabled -eq "true"} 

It searches against AD database to find user's with "PasswordNeverExpires" set to "True" then returns the results in the Powershell console.

edit for wording and wrong cmdlet and to add the below To cleanup the results add this to the end of the above powershell code

| Format-Table -Property Name, PasswordNeverExpires -AutoSize

Solution 2:

You could use something like this:

Get-ADUser -filter { (PasswordNeverExpires -eq $true) -and (enabled -eq $true)} -searchbase "OU=,OU=,DC=,DC=" -Properties Surname,givenname, userprincipalName,PasswordNeverExpires| FT Name,ObjectClass,PasswordNeverExpires -A