The following command does a DSquery to get a list of computer names from AD which are then filtered using the find /v and after the filter the remaining host are pinged and "Reply From" is searched for. If "Reply From" is found then Errorlevel is 0 indicating successful completion of the command. I can run the command but the files aren't being output. Everything else works correctly the second command works properly and outputs the files but the first one does not output files.
First Command:
for /f %a in ('dsquery computer -o rdn -limit 10000 ^| find /v /i "at0" ^| find /v /i "braboc" ^| find /v /i "branet" ^| find /v /i "vt0" ^| find /v /i "test"') do for /f %b in ('ping -n 1 %a ^| find "Reply From"') do if %errorlevel% GEQ 1 (echo %a >> c:\notup.txt) else echo %a >> c:\good.txt
Second Command:
for /f "tokens=1 delims=\" %a in ('net view ^| find /v /i "at0" ^| find /v /i "braboc" ^| find /v /i "branet"') do for /f %b in ('ping -n 1 %a ^| find /i "Reply"') do if %errorlevel%==1 (echo %a >> c:\notup.txt) else echo %a >> c:\good.txt