Cyber Security

List all logged on Users with quser.exe and PowerShell

In this short article I will show how to list all logged on local users with the quser.exe tool. Quser displays information about logged on users on the local computer and on a Remote Desktop Session Host server.

PowerShell Code

Enter the code below to determine all logged on users. Multiple users, if any, will be separated by comma.

$users = quser.exe | Select-Object -Skip 1
$unames = @()
foreach ($u in $users) {
    $uname = ($u.trim() -replace '\s+',' ' -replace '>','' -split '\s')[0]
    $unames += New-Object psobject -Property ([ordered]@{
                    'Logged in Users' = [string]$uname
Write-Output $unames

The code leads to the following output.

3 replies »

  1. Yes I’ve been using quser a long time to seek out disconnected sessions and their session numbers so that I can reset them on servers.
    Using quser /server: you can find the sessions of users logged on but disconnected then use reset session # /server: to reset those sessions. This is/has been helpful on many occasions. Maybe you can add the above into your ps example. 😊.

    Joost van Haaren

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.