Detect who is logged on to remote Windows machines
How do you find out who is logged on to remote windows machines?
I'm using psloggedon at the moment, but it gives me only one computer at a time.
psloggeon \\172.21.0.5
Is there a better way how to scan a whole subnet ? Preferably some GUI application.
not a GUI, but:
for /L %x in (2,1,254) do psloggedon \\172.21.0.%x
will do a scan from 172.21.0.2-254. You can also nest:
for /L %z in (16,1,31) do for /L %x in (1,1,254) do psloggedon \\172.21.%y.%x
This will scan the 172.21.{16-31}.x subnets.
I found this script. It scans a whole domain and gives you a nice output (computer name and user name).
whoisloggedinwhere.bat > users.txt
@echo off setlocal for /f "Tokens=1" %%c in ('net view /domain:"%USERDOMAIN%"^|Findstr /L /C:"\\"') do ( for /f "Tokens=*" %%u in ('PsLoggedOn -L %%c^|find /i "%USERDOMAIN%\"') do ( call :report %%c "%%u" ) ) 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%
This script uses PsLoggedOn.
Try nbtstat -a <computername>
I write the user name into the computer description property using a logon script, which lets me see everything in AD Users & Computers, do searches on it, and so on. Very handy.