Password Expiration

Yevrag35

Pushing Daisies on Saturn
Messages
1,118
Location
Wisconsin, US
Calling all HelpDesk people...

Do you have a way to figure out when/if your user's password expired?

I came with up with a Powershell script that's easy to use to determine how many days until a user's password is set to expire.

Code:
Import-Module ActiveDirectory
$ErrorActionPreference = "SilentlyContinue"
do {
    $user = Read-Host ("Enter Domain Username")
    Write ---
    $query = ((Get-ADUser -Identity $user -Properties msDS-UserPasswordExpiryTimeComputed)."msDS-UserPasswordExpiryTimeComputed")
    $results = (([datetime]::FromFileTime($query))-(Get-Date)).Days
    $0results = $results
    if ($query -eq "9223372036854775807")
        { Write-Host "$user has a password that is set to NOT expire." }
    else
        {
        if ($results -lt "0")
            {
            $0results *= -1
            Write-Host "The password for $user expired $0results day(s) ago."
            }
        else
            {
            Write-Host "The password for $user will expire in $results days."
            }
        }
    Write ---
    $exit = Read-Host ("Press x to close the session or Enter to repeat")
    Clear-Host
} until ($exit -eq "x")
Very handy for our Helpdesk person here to troubleshoot possible password expiration effects that one might have.

What it accounts for:
Person(s) whose password hasn't expired yet (obviously :p)
Person(s) whose password does NOT expire (at all)
Person(s) whose password has expired already
 
Last edited:
Very nice!

Too bad I don't work in a help desk anymore, lol.
Yeah, it would have been nice to have.

Our new helpdesk person asked if there was any to find out when someone's password would expire. At that point, I honestly couldn't answer him, and so I dug.
 
Back
Top Bottom