Home » PowerShell » Quser to Get List of Users Logged on Server

Quser to Get List of Users Logged on Server

While working on remote server, you may receive warning message from windows that “Someone else is still using this PC. If you shut down now, they could lose unsaved work” and you may not be able to login to computer. QUser command helps to identify active user sessions on the remote computer.

QUser Command - Someone else is still using this PC
Warning – Someone else is still using this PC

Use QUser PowerShell command to get users logged on to remote server or remote computer and find user logged on to a remote computer.

PowerShell QUser command displays information about users session on remote server. Using quser, you can get list of users logged on to the server machine.

QUser Command


quser [<username> | <sessionname> | <sessionID>] [/server:<servername>]


quser command accepts below parameters

  • <username> – the log on name of user that you want to query
  • <sessionname> – the name of session you want to query
  • <sessionid> – specifies the name of session id you want to query
  • /server:servername – specifies the name of remote computer server that you want to query
  • /? – display quser help

Above Quser command in PowerShell consider default as current machine for server name to be queried and returns the list of user logged on the current machine

QUser PowerShell command returns

  • USERNAME – name of the users currently logged on
  • SESSIONNAME – name of the session
  • ID – session id
  • STATE – Active or disconnected
  • IDLE TIME – quser idle time for a user in a number of minutes since the last keystroke or mouse movement at session
  • logon time – date and time the user logon to the server

Run PowerShell or cmd with administrator access privileges to avoid quser access denied error.

Cool Tip: Query Active Directory users info using PowerShell!

QUser Command Examples

QUser Command – To view users logged on to remote server system

quser /server:it-cor20

In the above QUser command, it takes quser /server parameter to get logged on user information about remote computer it-cor-20

It returns the list of all the users currently logged on to the remote desktop machine and prints output on console as below with logged on username, sessionname, sessionid, state, logon time

PS D:\LogTest> quser /server:it-cor20

 Tom       console     1    Active      None        27-07-2021 14:13

QUser command to get logged in user name on remote computer

$users = quser /server:it-cor20
foreach($user in $users)
    $Parsed_user = $user -split '\s+'
    #Get UserName
    Write-Host $Parsed_user[0]

In the above PowerShell script gets list of logged on user session to remote computer.

Using QUser /server command, it takes remote host name and gets the logged on users session to $users variable.

We then iterate over $users object using foreach to split user object string to get username and assigned it $Parsed_user and use Write-Host to print and view logged on users.

QUser logoff or disconnect user

Using PowerShell quser logoff command, you can logoff any user with session id or session name that you get using quser command

logoff 15 /server:it-cor20

In the above command, quser log off command disconnect session id 15 or logoff session quser from it-cor20 server.

Cool Tip: Learn different between Active Directory lastlogon and lastlogontimestamp!

Fix QUser Access Denied

Sometime you may get QUser access denied issues as below while trying to get logged on users information on computer

Error 0x00000005 enumerating sessionnames
Error [5]:Access is denied.

To fix QUser access denied issue, open cmd in administrator mode and for UAC remote restrictions, modify registry on remote computer.

Refer UAC and Remote restriction

Important Note: Do back up of registry file before making any changes.


Hope you find out above article helpful and educational to get list of logged on users on remoter server using quser command in PowerShell .

QUser logoff command will disconnect session user using session id or session name.

You will need to have full access or special access to run quser PowerShell command else it will give you remote server access denied message. if you don’t specify server name, it uses current server as default to query and returns the users.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on ShellGeek home page.

Leave a Comment