Check who currently logged into server from command line?

I am at my workstation.  The server I RDP into has all of the connections taken.  My question is this.  Is there a way to check who is currently logged into that server via my command line?
donnatroniousAsked:
Who is Participating?
 
Nirmal SharmaSolution ArchitectCommented:
Run the following command from your workstation:

Psexec.exe \\computer_name cmd.exe /c SET %username% > Output.txt 2>&1

Open output.txt and look for username.

The following script lets you to save the result in a CSV format file for all computers:

@echo off
Srvlist=C:\Temp\Srvlist.txt
Echo Computer Name, Logged On User Name >> Result.csv
SET Usr_name=
For /F Tokens=* %%a In (%srvlist%) Do (
Set Comp_name=%%a
Psexec.exe \\%comp_name cmd.exe /c SET %username% > Output.txt 2>&1
For /f "Tokens=3" %%b in (Output.txt) DO SET Usr_name=%%b
Echo %Comp_name%, %Usr_name% >> Result.csv
)
0
 
aissimCommented:
This MS/Sysinternal utility may do the trick for ya:
http://www.microsoft.com/technet/sysinternals/utilities/psloggedon.mspx
0
 
Brian PiercePhotographerCommented:
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
MSE-dwellsCommented:
Use -

query user

... or -

query session

In addition, I recently wrote a script that destroys _INACTIVE_ sessions on Windows Terminal Servers.  It's available here you think if it will beof use -

ftp://falcon.msetechnology.com/scripts/tsdestroy.cmd.txt
0
 
Nirmal SharmaSolution ArchitectCommented:
MSE - good job!
0
 
MSE-dwellsCommented:
Glad it helped ... feel free to comment back here if you'd like any additional (within reason ;0) features.
0
 
sabkCommented:
You can also check without run batch  in command prompt type      
qwinsta /server:IPAddress or Name
0
 
mckockinerCommented:
quser
0
 
IvorStonesCommented:
echo %userdomain%\%username%
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.