windows 确定密码到期日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4794911/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Determine password expiry date
提问by JB_SO
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.
我有一个 Windows XP 系统,用户帐户被配置为在 45 天后设置密码过期选项。我试图弄清楚,无论是手动还是通过使用批处理文件,密码到期日期是基于当前登录的用户。我知道有 VBScript 文件可以做到这一点,但这些 pc 的配置为不执行 VBScript 文件,因此我需要手动查找或批处理文件。
Thanks!
谢谢!
回答by user825315
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)
多台机器为一个用户帐户远程运行...将所有计算机名称或 IP 放在一个文本文件中(即 systems.txt)
psexec @systems.txt net user username | findstr "expires"
psexec is free from sysinternals
psexec 不受 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...
如果您想知道多台网络计算机上所有本地用户的到期日期,您可以使用 powershell 和 psexec(远程机器不需要 powershell),就像这样......
$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.
您可能需要稍微调整脚本...希望这会有所帮助。