Recently I needed to retrieve the account enabled status and password information from Active Directory for a small number of users. I created this script to quickly retrieve their password and enabled data.


$usernames = @('testuser','testuserm','johnsona','administrator','guest')
$filter = [scriptblock]::create(($usernames| foreach {"(samAccountName -eq '$_')"}) -join ' -or ')

Get-ADUser -Filter $filter -Properties PasswordLastSet, PasswordExpired, PasswordNeverExpires | Format-Table Name, PasswordLastSet, PasswordExpired, PasswordNeverExpires, Enabled

Account Enabled and Password Information

Account Enabled and Password Information