Find and modify domain accounts with non-expiring passwords (PowerShell)

To find all the accounts with non-expiring passwords, run the following cmdlet in PowerShell:

Get-ADUser -Filter {Enabled -eq $true -and PasswordNeverExpires -eq $true}

To enable password expiration for the accounts that were found from the above cmdlet, run the following in PowerShell:

Get-ADUser -Filter {Enabled -eq $true -and PasswordNeverExpires -eq $true} | Set-ADUser -PasswordNeverExpires $false

Was this article helpful?

Related Articles

Leave A Comment?