Saturday, April 20, 2024
HomePowershellChecklist all logged on Customers with quser.exe and PowerShell – SID-500.COM

Checklist all logged on Customers with quser.exe and PowerShell – SID-500.COM


Cyber Safety

On this quick article I’ll present how one can record all logged on native customers with the quser.exe device. Quser shows details about logged on customers on the native laptop and on a Distant Desktop Session Host server.

PowerShell Code

Enter the code under to find out all logged on customers. A number of customers, if any, can be separated by comma.

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

The code results in the next output.

Revealed by Patrick Gruenauer

Microsoft MVP on PowerShell [2018-2023], IT-Coach, IT-Guide, MCSE: Cloud Platform and Infrastructure, Cisco Licensed Academy Teacher.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments