Determine password expiry date

11,685

If this is just on one computer, one user, and ran locally...

net user username | findstr "expires"

Multiple machines ran remotely for one user account... put all computer names or IP's in a text file (i.e. systems.txt)

psexec @systems.txt net user username | findstr "expires"

psexec is free from sysinternals

If you want to know the expiration date on all local users on multiple network computers you can use powershell and psexec (remote machines do not require powershell), like so...

$systems = get-content .\systems.txt;
foreach ($sys in $systems) {
foreach ($token in (Get-WmiObject Win32_UserAccount -ComputerName $sys -Filter "Domain='$sys'" | Select-Object -Property Name |ft -AutoSize -HideTableHeaders >> "$sys.txt")) { echo $token };
(cat "$sys.txt") -replace ' {2,}','' | ? {$_ -ne ''} | sc "$sys.txt"
foreach ($strUser in (get-content "$sys.txt")) {psexec \\$sys net user $strUser >> "$sys-accounts.txt"
}
}

you may need to tweak the script a little... hope this helps.

Share:
11,685
JB_SO
Author by

JB_SO

Updated on June 15, 2022

Comments

  • JB_SO
    JB_SO almost 2 years

    I have a Windows XP system and the user accounts are configured to have their passwords expire in 45 days option set. I am trying to figure out, either manually or via the use of a batch file, what the password expiry date is based on the current user logged in. I know that there are VBScript files that can accomplish this, but these pc's are configured to not execute VBScript files, therefore I need to either look this up manually or batch files.

    Thanks!

  • Robbie Dee
    Robbie Dee over 9 years
    If someone else passing finds that the net user command doesn't work, try: net user username /domain | findstr "expires"