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:

"Windows Server 2003" - to return only those computers running Windows Server 2003.                              "Windows XP Pro"      - to return only those computers running Windows XP Professional.                              Server                - to return all computers running any Windows Server.                              Windows               - to return all Windows computers.                              XP                    - to return all Windows XP-based computers.                              The output is displayed on the console, but you can pipe it to a file using:                              GetComputer OperatingSystemi>FileName                              You can perform subsequent processing on the computer names returned using:                              for /f %%c in ('GetComputer OperatingSystem1 OperatingSystem2') do (                               @echo %%c                              )                              where @echo represents any command.                              GetComputer.bat contains:                              @echo off                              setlocal                              If \{%1\}

\{\} set os=*&goto loop1 :loop if \{%1\}

\{\} endlocal&exit /b 0 set os=%1 set os=*%os:"=%* shift :loop1 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