Using a filtered DSQUERY command, I have scripted GetComputer.bat to return the NetBIOS computer names in your domain whose operating system matches a specified string.

The syntax for using GetComputer.bat is:

GetComputer \[OperatingSystem1 OperatingSystem2 ... OperatingSystemN\]

where OperatingSystemi is any string that matches all or a portion of the operating system name. If NOT specified, all operating systems are returned. Examples of valid OperatingSystemi entries are:

<b>"Windows Server 2003"</b> - to return only those computers running <b>Windows Server 2003</b>.
<b>"Windows XP Pro"</b>      - to return only those computers running <b>Windows XP Pro</b>fessional.
<b>Server</b>                - to return all computers running any Windows <b>Server</b>.
<b>Windows</b>               - to return all <b>Windows</b> computers.
<b>XP</b>                    - to return all Windows <b>XP</b>-based computers.

The output is displayed on the console, but you can pipe it to a file using:

<b>GetComputer OperatingSystem<i>i</i>>FileName</b>

You can perform subsequent processing on the computer names returned using:

for /f %%c in ('<b>GetComputer OperatingSystem1 OperatingSystem2</b>') do (
 @echo %%c

where <b>@echo</b> represents any command.

<b>GetComputer.bat</b> contains:

@echo off
If \{%1\}<h1><a name="_set_os_amp_goto_loop1_loop_if_1_">\{\} set os=*&goto loop1
if \{%1\}</a></h1>\{\} endlocal&exit /b 0
set os=%1
set os=*%os:"=%*
set query="(&(objectClass=Computer)(operatingSystem=%os%))" -attr name -limit 0
for /f "Skip=1 Tokens=*" %%c in ('dsquery * domainroot -filter %query%') do (
 @echo %%c
goto :loop