In this short port I publish PS script which in easy way is checking when user password is expired (or when will expire). I am using this in my daily work.
This is very simple code. It is getting from user some part of name or surname of AD account, then is searching account and lists all matched entries together with creation date and password expire date.
1 2 3 4 5 6 7 8 |
$surname= Read-Host "Who has problem ? " $surname= "*" + $surname+ "*" Get-ADUser -filter {DisplayNAme -like $surname} –Properties "DisplayName", "userprincipalname", "msDS-UserPasswordExpiryTimeComputed", "PasswordLastSet" | Select-Object -Property "Displayname","userprincipalname", "PasswordLastSet", @{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}} |
that is the result: