从AD批量获取用户名和PWD过期 [英] Batch Obtain Usernames and PWD Expiration From AD

查看:187
本文介绍了从AD批量获取用户名和PWD过期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个文本文件,上面有所有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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆