I've come across this batch script which essentially fires up psloggedon (by Symantec) for each IP on the domain and then neatly writes the output to a text file. I was wondering if there is a way to get it to read a lists of hosts from a text file instead so that I can query a set list of computers without having to do the whole domain.
From my understanding, currently it gets a list of everything on the domain using net view and then fires up PsLoggedOn for each and writes the results to an output file.
Here's the batch as it stands:
Code: Select all
@echo off
echo %date% >> C:\Output.txt
echo %time% >> C:\Output.txt
setlocal EnableDelayedExpansion
for /f "Tokens=1" %%c in ('net view /domain:"%USERDOMAIN%"^|Findstr /L /C:"\\"') do (
set isloggedon=0
for /f "Tokens=*" %%u in ('PsLoggedOn -L %%c^|find /i "%USERDOMAIN%\"') do (
set isloggedon=1
call :report %%c "%%u"
)
if !isloggedon!==0 call :report %%c nobody
)
endlocal
goto :EOF
:report
set work=%1
set comp=%work:~2%
set user=%2
set user=%user:"=%
call set user=%%user:*%USERDOMAIN%\=%%
@echo %comp% %user%
Echo %comp% , %user% >> C:\Output.txt
Any help would be much apprechiated, thanks.