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.
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 )
Person(s) whose password does NOT expire (at all)
Person(s) whose password has expired already
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")
What it accounts for:
Person(s) whose password hasn't expired yet (obviously )
Person(s) whose password does NOT expire (at all)
Person(s) whose password has expired already
Last edited: