Using NETDOM from the Windows 2000 Support Tools, or NETDOM from
the .NET Server
support tools, or NETDOM from the Windows XP support tools, and $poslen,
I have scripted Computers.bat.
The syntax for using Computers.bat is:
Computers Objects
where Objects is a string made up of one or more of the following computer types:
W - Member Workstations
S - Member Servers
P - PDC (emulator)
D - Domain Controllers.
Sample Usage
To generate a file of all the computers in your domain:computers WDS>Drive:\Folder\Computers.txt
To process all the computer names in a batch file:
@echo off setlocal for /f "Tokens=*" %%a in ('computers WSD') do call HideFromAddRemove "\\%%a" "Microsoft Windows Critical Update Notification" endlocal goto :EOF
Computers.bat contains:
@echo off setlocal if \{%1\}\{\} goto syntax set object=%1 set object=%object:"=% set /a cnt=0 :verify call $poslen %object% %cnt% 1 if /i "%$substring%" EQU "W" set /a cnt=%cnt% + 1&goto verify if /i "%$substring%" EQU "S" set /a cnt=%cnt% + 1&goto verify if /i "%$substring%" EQU "P" set /a cnt=%cnt% + 1&goto verify if /i "%$substring%" EQU "D" set /a cnt=%cnt% + 1&goto verify if /i not "%$substring%"
"ECHO is on." goto syntax set /a cnt=0 :loop call $poslen %object% %cnt% 1 if /i "%$substring%" EQU "W" set ot=WORKSTATION&goto loopinc if /i "%$substring%" EQU "S" set ot=SERVER&goto loopinc if /i "%$substring%" EQU "P" set ot=PDC&goto loopinc if /i "%$substring%" EQU "D" set ot=DC&goto loopinc endlocal goto :EOF :loopinc set /a cnt=%cnt% + 1 For /f "Skip=1 Tokens=1" %%i in ('netdom query %ot%') do call :computer "%%i" goto loop :Syntax @echo Syntax: Computers Objects endlocal goto :EOF :computer set machine=%1 set machine=%machine:"=% if "%machine%" EQU "The" goto :EOF if "%machine%" EQU "Directory" goto :EOF call set machine=%%machine:.%USERDNSDOMAIN%^=%% @echo %machine%
0 comments
Hide comments