显示域中所有电脑的批处理代码
Batch code to show all pc's in a domain
我试图查找一些东西,但找不到我要找的东西。
我想要一个可以做到这一点的代码:
- 扫描域中所有连接到该域的电脑(在线和离线(如果可能))。
- 然后我想将所有这些名称写入一个文件(我想我可以做到)
- 之后它应该在另一个文件中有一个代码来为文件中的每台电脑执行一些命令(我已经写好了)。
所以它看起来像这样:
GetSysteminfo.bat
Scan domain for every pc >> PcNames.txt
For %%EveryPC IN (PcNames.txt) Do (
Commands (i will post them if neccesary)
)
输出文件如下所示:
PcInfo.txt
PC01
information
PC02
information
PC03
information
etc.
我希望你能理解我想要得到的东西。
在此先感谢您的帮助。
您将需要工具 netdom
(https://technet.microsoft.com/en-us/library/cc772217.aspx) 和域管理凭据。
那么你可能
for /f "tokens=*" %%a in ('netdom query WORKSTATION') do (
echo %%a >>results.txt
yourcommand %%a >>results.txt
echo. >>results.txt
)
我试图查找一些东西,但找不到我要找的东西。
我想要一个可以做到这一点的代码:
- 扫描域中所有连接到该域的电脑(在线和离线(如果可能))。
- 然后我想将所有这些名称写入一个文件(我想我可以做到)
- 之后它应该在另一个文件中有一个代码来为文件中的每台电脑执行一些命令(我已经写好了)。
所以它看起来像这样:
GetSysteminfo.bat
Scan domain for every pc >> PcNames.txt
For %%EveryPC IN (PcNames.txt) Do (
Commands (i will post them if neccesary)
)
输出文件如下所示: PcInfo.txt
PC01
information
PC02
information
PC03
information
etc.
我希望你能理解我想要得到的东西。 在此先感谢您的帮助。
您将需要工具 netdom
(https://technet.microsoft.com/en-us/library/cc772217.aspx) 和域管理凭据。
那么你可能
for /f "tokens=*" %%a in ('netdom query WORKSTATION') do (
echo %%a >>results.txt
yourcommand %%a >>results.txt
echo. >>results.txt
)