Using the NET VIEW command, and Psloggedon freeware, I scripted WND.bat to report which computers that are NOT in my logged-on domain have local users logged on.
NOTE: See tip 9555 » How can a script return the domains and workgroups on my network?
The syntax for using WND.bat is:
WND
The output is displayed on the console, in a CSV format:
"Domain Or Workgroup","Computer Name","User Name"
Sample:
"WORKGROUP","\\JSI003","JSI003\Jerry"WND.bat contains:
@echo off setlocal ENABLEDELAYEDEXPANSION for /f "Skip=3 Tokens=*" %%d in ('net view /DOMAIN^|FIND /V "The command"^|FIND /V /I "%USERDOMAIN%"') do ( for /f "Tokens=1" %%x in ('@echo %%d^|FIND /V "The command"') do ( for /f "Tokens=1" %%c in ('net view /DOMAIN:%%d ^|FIND "\\"') do ( set usr=%%c set usr=!usr:\=! for /f "Tokens=*" %%u in ('PsLoggedOn -L -X %%c^|FINDSTR /I "!usr! %%d"') do ( @echo "%%x","%%c","%%u" ) ) ) ) endlocal
0 comments
Hide comments