@echo off echo 域内未分组计算机监视 echo 如果找到计算机,将显示找到的计算机列表,并通过PC喇叭提示。 echo. cd /d %~dp0 rem 设置NETBIOS域名 set domain=DOMAINNAME rem 设置域名 set DC=mydomain set DC1=com :loop set found=0 rem 搜素comouters for /f %%i in ('dsquery computer CN^=Computers^,DC^=%DC%^,DC^=%DC1%') do set found=1 rem 如果找到计算机,调用显示模块 if %found%==1 call :display ping -n 600 127.0.0.1 >NUL 2>&1 goto loop goto :eof :display echo %date% %time% found following computers: rem 读取计算机AD路径,并调用显示信息模块 for /f %%i in ('dsquery computer CN^=computers^,dc^=%DC%^,dc^=%DC1%') do call :info %%i goto :eof :info set dsname=%1 set dsname1=//%DC%.%DC1%/%dsname:"=% rem 获取计算机名 for /f "tokens=2,3* delims=,=" %%i in ('echo %dsname%') do set name=%%i rem 显示计算机权限,并显示可以设置DNS信息的权限用户(加域的人),dscals需要安装Support Tools dsacls %dsname1% |find "%domain%" |find "DNS" >name.txt 2>&1 for /f "tokens=1,2,3*" %%i in (name.txt) do set user=%%j echo %name%,%user% rem 记录信息 echo %name%,%user%>>"%date%.csv" rem beep报警,beep自己写或到网上找 echo. Beep 1500 500 Beep 500 500 Beep 1500 500 Beep 500 500 Beep 1500 500 Beep 500 500 Beep 1500 500 Beep 500 500 goto :eof