从AD批量获取用户名和PWD过期 [英] Batch Obtain Usernames and PWD Expiration From AD
问题描述
我目前有一个文本文件,上面有所有AD用户.使用以下命令,可以获取PWD到期日期的管道列表,但是我无法将用户名与到期日期配对以获得准确性.有人可以协助吗?警告:需要批量处理:(
I currently have a text file with all AD users on it. Using the following, I can get a piped list of expiration dates for PWD but I am unable to get the Username paired with the expiration for accurracy. Can anyone assist? Caveat: needs to be batch :(
for /F %%i in (users.txt) do net user %%i /domain | find "Password expires" >> passwordexp.txt
推荐答案
当您需要时,您已经拥有了所需的所有信息,只需将其打印出来即可:-)
You already have all the info you need when you need it, you just need to print it out :-)
您可以使用括号在DO子句中执行多个命令.
You can use parentheses to execute multiple commands in your DO clause.
您可以使用SET/P打印信息,末尾不用换行符.
You can use SET /P to print information without a newline at the end.
将整个结构括在圆括号中并将输出直接定向到文件一次更有效.
It is more efficient to enclose the entire construct in parentheses and direct the output to a file just once.
@echo off
(
for /F %%i in (users.txt) do (
<nul set /p "=%%i: "
net user %%i /domain | find "Password expires"
)
)>passwordexp.txt
这篇关于从AD批量获取用户名和PWD过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!