所以,我有一个在我的Windows活动目录networking上的5000台计算机的列表,可能会或可能不存在(我知道,不要问…我需要知道一个项目,当然networking人员帮助不大,他们给我的数据有太多的错误)
计算机名称属于SAT1至SAT5000。 但是,其中一些可能已升级到新的操作系统并重新命名。 所以在这种情况下,我想要检测新的名字。
我不知道是否有人可能会有一个脚本,给出一个文本文件,其中包含一个计算机名称列表,每个:1. ping计算机检查存在(是的,它必须是,我知道)
2.从第一个ping接收到ip后,执行ping -a命令获取主机名
3.将结果写入文本文件
(甚至更好…有可能以某种方式将初始文件拆分为多个文件,产生多个batch file以同时运行,以减慢同步ping 5000台机器的速度慢)
这篇文章似乎有点相关,我在找什么: http : //www.enterpriseitplanet.com/networking/features/article.php/1571771
这是我结束了:
@echo off rem del output.txt rem Loop thru list of computer names in file specified on command-line for /f %%i in (%1) do call :check_machine %%i goto end :check_machine rem Check to see if machine is up. echo %1 ping -n 2 %1 >NUL 2>NUL if errorlevel 1 goto down rem Reverse-lookup machine name and report for /f "usebackq tokens=2,3" %%d in (`ping -n 1 -a %1 ^| find "Pinging "`) do echo %1, %%d,%%e >> output.txt goto end :down rem Report machine down echo %1 >> output.txt :end
输出格式如下:
SAT10 SAT1209 SAT601, CGY2601.na.sat.com,[110.3.111.70] SAT3592, CGY3592.na.sat.com,[110.0.237.45]
如果将计算机列表拆分为多个较小的文件,则可以像这样asynchronous执行ping操作:
del output.txt start MassPing.cmd Computers1.txt start MassPing.cmd Computers2.txt start MassPing.cmd Computers3.txt start MassPing.cmd Computers4.txt start MassPing.cmd Computers5.txt start MassPing.cmd Computers6.txt
这里有一个batch file给你:
@echo off rem Loop thru list of computer names specified on command-line for /f %%i in (%1) do call :check_machine %%i goto end :check_machine rem Check to see if machine is up. ping -n 2 %1 >NUL 2>NUL if errorlevel 1 goto down rem Reverse-lookup machine name and report for /f "usebackq tokens=2" %%d in (`ping -n 1 -a %1 ^| find "Pinging"`) do echo %1:Up:%%d goto end :down rem Report machine down echo %1:Down :end
传递一个文本文件,其中包含计算机名称列表,它将PING它们(2次尝试 – 您可以通过增加第一个PING命令行中的“-n”之后的数字来增加该次数),如果它获得一个响应,执行名称的反向查找。 它返回结果为:
computer-name-1:Up:name-it-resolved-to computer-name-2:Down computer-name-3:Up:name-it-resolved-to ...
要并行运行多个文件,只需使多个文本文件具有不同的机器名称列表并同时启动几个副本即可。
快速和肮脏的一天保存。
你真的需要平? 计算机帐户将每30天自动更改密码。 在200/2003/2008function级别上,您可以使用dsquery computer -stalepwd X ,其中X是自上次密码更改以来的天数。 这个过程通常是通过将响应这个的计算机帐户移动到“OLD”OU来实现的,然后在30-90天之后,如果密码仍然没有改变,它们将被自动删除。
您也可以使用nmap进行扫描:
nmap -sn -PE -oG scan.txt 192.168.1.1 192.168.2.0/24
从手册页引用:
-sn: Ping Scan - disable port scan The default host discovery done with -sn consists of an ICMP echo request, TCP SYN to port 443, TCP ACK to port 80, and an ICMP timestamp request by default. -oN/-oX/-oS/-oG <file>: Output scan in normal, XML, s|<rIpt kIddi3, and Grepable format, respectively, to the given filename. -PE; -PP; -PM (ICMP Ping Types) . In addition to the unusual TCP, UDP and SCTP host discovery types discussed previously, Nmap can send the standard packets sent by the ubiquitous ping program. Nmap sends an ICMP type 8 (echo request) packet to the target IP addresses, expecting a type 0 (echo reply) in return from available hosts. [...] Use the -PE option to enable this echo request behavior.
scan.txt看起来像这样:
# Nmap 5.50 scan initiated Fri Aug 19 17:59:59 2011 as: nmap -vv -sn -PE -oG /tmp/scan.txt 192.168.1.1 192.168.2.0/24 # Ports scanned: TCP(0;) UDP(0;) SCTP(0;) PROTOCOLS(0;) Host: 192.168.1.1 () Status: Down Host: 192.168.2.0 (www.dummy.example.org) Status: Up Host: 192.168.2.1 (www.foo.example.org) Status: Down ... # Nmap done at Fri Aug 19 18:03:26 2011 -- NNN IP addresses (1 host up) scanned in 4.02 seconds
另一种可能适用于您的方法是让“networking专家”吐出DHCP服务器租约。 Ping 5000台电脑需要一段时间。
我也有类似的需要为数千台计算机执行此操作,并开发了一个PowerShell脚本来处理它。 此脚本并行运行多个后台作业以加速ping过程,并可以select执行DnsLookup来查找IP地址和完全限定的域名。 性能会因遇到多less超时而有所不同,但是我已经在15分钟内为12,000个主机完成了脚本。
脚本太大,无法在这里发布,但是您可以在这里看到(并下载)它:
http://poshtips.com/2011/03/28/bgping-a-high-performance-bulk-ping-utility/
这可能不是你想到的,但是我为此目的使用的一个工具是Networkview 。 它会揭示超过你的要求,将花费几美元,但是非常值得的价格。 对于一次性,您可以在评估模式下使用它。
你想要做的事是错的,我的朋友。
首先解决问题,你有一个根,并且该根在Active Directory中。 所以请确保老化设置正确,并且将dnslogging设置为正确清除。
比getba列表与你们所有的ip,s在dns中,并ping他们你Active Directory。
如果ip未知比pc已经死了,你可以禁用它。
这是困难的方式。
简单的方法是艰难的:
在命令提示符下运行这个命令,但要确保你是域pipe理员,并在你的windows版本中安装了windows支持工具。 你可以从微软网站下载它们,或者从任何Windows XP或Server 2003安装它们,具体取决于你正在运行的操作系统。
dsquery电脑上次login
可能你会想要像dsquery计算机最后login> C:\ deadpc.txt现在你去所有的法医与这一起去。 dsquery computer -disabled> c:\ disabledpc.txt先清理那些
当你把大部分的东西弄到外面的时候,你可能要检查重复的SID