|
Answer» 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.
I've tried variations of the if statement, but no output.
I know I can use a BATCH file to produce but I've been experimenting with single line commands and wanted to see at which point will the Windows Command shell break
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
|