Get-CimInstance -ClassName Win32_LogonSession -Filter "LogonType = 10" will get you the logged on users. You can use -ComputerName to run it on a remote computer, or create an array of CimSessions and pass that to -Session to automatically parallelize it across many systems. Answer from 0x2369 on reddit.com
🌐
Reddit
reddit.com › r/powershell › how to get a list of users connected via remote desktop sessions (terminal services) on a remote computer.
r/PowerShell on Reddit: How to get a list of users connected via remote desktop sessions (terminal services) on a remote computer.
March 6, 2020 -

Hi guys,

I have a bit of an odd request here. I have a requirement to pull a list of currently signed-in Remote Desktop (both active and disconnected) users on a remote system via powershell.

If at all possible, I would prefer to avoid using query user (quser) or query session (qwinsta) simply due to the length of time it can take to retrieve the data using those commands, as well as in the environment that I'm in, they only appear to work about 15-20% of the time.

I would also prefer to avoid installing any additional powershell modules if I can, since some of the networks I will be running this script on wont have any connection to the internet to pull the modules from.

I have looked at pulling a list of all users on the system who have an 'Explorer.exe' process running, but that doesn't differentiate between locally signed in users and remote users.

I'm running into a bit of a wall here, I cant seem to find anything online that would fit the bill.

Discussions

windows - How to get all remote computer's usernames via Powershell? - Stack Overflow
Is there any way to get list of all local user accounts on a remote computer via Powershell? More on stackoverflow.com
🌐 stackoverflow.com
May 22, 2017
shell script - how to list users in linux?…local, remote, real and all users - Unix & Linux Stack Exchange
How to list users in Linux? Specifically, local, remote, real and all users. I have multiple Linux servers in the same network. I want to list all the users listed in all the servers in a single sh... More on unix.stackexchange.com
🌐 unix.stackexchange.com
List of computers - Need to find which user is logged in
Try this quick and nasty script and just calls "quser" for each of the remote computers.. It assumes a few things, this worked for me, but all my machines are AD joined, and i was running as administrator. The list of computers in the file c:\xfer\computers.txt with each computer on a separate line. $computers = Get-Content "C:\xfer\computers.txt" foreach ($computer in $computers) { Write-Host "" Write-Host "Checking Computer $computer" quser /server:$computer } More on reddit.com
🌐 r/PowerShell
8
0
January 13, 2023
Pull list of mapped drives remotely?
Take a look at Get-PSDrive. Open a PSSession via Enter-PSSession and type in Get-PSDrive. This will list all of the "Drives" of the remote machine. There's obviously a lot more code to customize what you want to see, but take a look here: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-psdrive?view=powershell-5.1 More on reddit.com
🌐 r/sysadmin
15
8
November 6, 2017
Top answer
1 of 3
1

It (csv file) should be formatted as follows:

computername
server1
server2
server3

'Computername' is the column name. This can be derived from the code snippet as the Foreach-Object refers to the ComputerName property.

2 of 3
0

Try this

function Get-MyLoggedOnUsers
{
  param([Array]$Computer)
  Get-WmiObject Win32_LoggedOnUser -ComputerName $Computer |
  Select __SERVER, Antecedent -Unique |
  %{"{0} : {1}\{2}" -f $_.__SERVER, $_.Antecedent.ToString().Split('"')[1],       $_.Antecedent.ToString().Split('"')[3]}
}

$Computers = gc C:\Temp\Computers.txt

Get-MyLoggedOnUsers $Computers

-or-

I found this one and modified it to my needs

<#
.Synopsis
Queries a computer to check for interactive sessions

.DESCRIPTION
This script takes the output from the quser program and parses this to PowerShell objects

.NOTES   
Name: Get-LoggedOnUser
Author: Jaap Brasser
Version: 1.1
DateUpdated: 2013-06-26

.LINK
http://www.jaapbrasser.com

.PARAMETER ComputerName
The string or array of string for which a query will be executed

.EXAMPLE
.\Get-LoggedOnUser.ps1 -ComputerName server01,server02

Description:
Will display the session information on server01 and server02

.EXAMPLE
'server01','server02' | .\Get-LoggedOnUser.ps1

Description:
Will display the session information on server01 and server02
#>
param(
[CmdletBinding()] 
[Parameter(ValueFromPipeline=$true,
           ValueFromPipelineByPropertyName=$true)]
[array[]]$ComputerName = (gc C:\Temp\TSRA.txt)
)

process {
foreach ($Computer in $ComputerName) {
    quser /server:$Computer | Select-Object -Skip 1 | ForEach-Object {
        $CurrentLine = $_.Trim() -Replace '\s+',' ' -Split '\s'
        $HashProps = @{
            UserName = $CurrentLine[0]
            ComputerName = $Computer
        }

        # If session is disconnected different fields will be selected
        if ($CurrentLine[2] -eq 'Disc') {
                $HashProps.SessionName = $null
                $HashProps.Id = $CurrentLine[1]
                $HashProps.State = $CurrentLine[2]
                $HashProps.IdleTime = $CurrentLine[3]
                $HashProps.LogonTime = $CurrentLine[4..6] -join ' '
        } else {
                $HashProps.SessionName = $CurrentLine[1]
                $HashProps.Id = $CurrentLine[2]
                $HashProps.State = $CurrentLine[3]
                $HashProps.IdleTime = $CurrentLine[4]
                $HashProps.LogonTime = $CurrentLine[5..7] -join ' '
        }

        New-Object -TypeName PSCustomObject -Property $HashProps |
        Select-Object -Property UserName,ComputerName,SessionName,Id,State,IdleTime,LogonTime
    } | Out-GridView -Title "Users Logged in $Computer"

   }
}
🌐
Microsoft Learn
learn.microsoft.com › en-us › windows-server › administration › windows-commands › query-user
query user | Microsoft Learn
November 1, 2024 - To find out what's new in the latest version, see What's New in Remote Desktop Services in Windows Server. query user [<username> | <sessionname> | <sessionID>] [/server:<servername>] To use this command, you must have Full Control permission ...
🌐
Microsoft
devblogs.microsoft.com › dev blogs › scripting blog [archived] › hey, scripting guy! how can i list all user profiles on a remote computer?
Hey, Scripting Guy! How Can I List All User Profiles on a Remote Computer? - Scripting Blog [archived]
December 1, 2009 - The command to list remote profiles and display the results in a table follows is shown here: Get-WmiObject -Class win32_userprofile -ComputerName win7-pc | Format-Table –property sid, localpath –AutoSize
Find elsewhere
🌐
Lepide
lepide.com › how-to › list-all-user-accounts-on-a-windows-system-using-powershell.html
PowerShell Get-LocalUser to List All Local Users on Windows
November 20, 2024 - Get-LocalUser is limited to listing accounts on the system where the command is run. But Get-WmiObject queries local users on remote systems using Windows Management Instrumentation (WMI). Get-WmiObject -ComputerName workstation1 -Class Win32_UserAccount -Filter "LocalAccount=True"
🌐
DevOps on Windows
devopsonwindows.com › home › articles › 3 ways to remotely view who is logged on
3 Ways to Remotely View Who Is Logged On
September 2, 2014 - @REM start %servicename% service ... the time. Run this on PowerShell console · Full command: Get-WmiObject Win32_ComputerSystem -ComputerName | Format-List Username...
🌐
Petri
petri.com › home › windows server 2012 r2: get a list of active remote desktop users
Windows Server 2012 R2: Get a list of active Remote ...
June 4, 2025 - If you want to query users on a remote computer, just add the /SERVER parameter followed by the name of the remote server. ... Similar to quser, qwinsta displays users logged in to a RD Session Host, along with information about whether at the ...
🌐
Reddit
reddit.com › r/powershell › list of computers - need to find which user is logged in
r/PowerShell on Reddit: List of computers - Need to find which user is logged in
January 13, 2023 -

Hi

I have a list of computer names and need to find the users who are using these computers.

How to fetch these users details via powershell?

Thanks

🌐
Windows OS Hub
woshub.com › find-current-user-logged-remote-computer
Find the Current User Logged on a Remote Computer | Windows OS Hub
March 15, 2024 - Use the Get-ADComputer cmdlet to get the list of computers in the domain. In the example below, we will get the usernames logged on active computers in the specific domain OU. To make the script work faster before accessing a remote computer, ...
🌐
AirDroid
airdroid.com › home › remote support › how to see who is logged into a remote computer? [2025]
How to See Who Is Logged into a Remote Computer? [2025]
April 3, 2025 - Here's how to use it: Step 1: Firstly, right-click on the taskbar and select "Task Manager." Or you can use the Ctrl + Shift + Esc key combination to open Task Manager. Step 2: After that, look for a dedicated "Users" tab (availability depends ...
🌐
The Lonely Administrator
jdhitsolutions.com › powershell › getting local user accounts the powershell way
Getting Local User Accounts the PowerShell Way • The Lonely Administrator
February 10, 2016 - The function connects to the remote computer and then uses some COM object voodoo, to enumerate local account information. By default, the command will list all user accounts. Or you can specify a single user account name. The function accepts pipeline input making it easy to check multiple servers at once...
🌐
AnyViewer
anyviewer.com › how-to articles › how to check users logged in remote desktop [full guide]
How to Check Users Logged in Remote Desktop [Full Guide]
December 13, 2024 - Now, you can use this command to see who is logged into a remote computer. In the "Remote Desktop Services Manager" interface, click on the "Users" tab to see all details about the users.
🌐
Petri
petri.com › home › powershell problem solver: how to find and list local user accounts using powershell
How to Find & List Local User Accounts Using PowerShell
June 5, 2025 - By the way, if you need to use alternate credentials, you will need to create CIMSessions for each remote computers. My examples have been ad-hoc with PowerShell setting up and tearing down temporary CIMSessions. ​$csess = new-cimsession -ComputerName $computers -Credential globomanticsadministrator · Now I have a collection of CIMSessions, which I can use like this: ​get-ciminstance win32_useraccount -filter "name='LocalAdmin'" -CimSession $csess | Select Name,Disabled,PSComputername
🌐
Bradley Schacht
bradleyschacht.com › find-users-logged-into-remote-computer
Find Users Logged Into Remote Computer
May 24, 2024 - If you want to check multiple computers just create a list in notepad and save it as a batch file to run. This clearly won't work for a large quantity of servers, but it worked great for the 6 servers I needed to check. Unfortunately if the user does not have the appropriate permissions on the server they will not get ...
🌐
ManageEngine
manageengine.com › products › active-directory-audit › powershell › get-remote-logged-on-user-with-powershell.html
How to remotely see what users are logged into Windows | ManageEngine ADAudit Plus
April 4, 2025 - ADAudit Plus will automatically scan all DCs in the domain to retrieve information about the users currently logged on remotely to a computer, generate the report and present it in a simple and intuitively designed UI.
🌐
MSPoweruser
mspoweruser.com › home › windows › see who is logged into a remote computer: 6 best ways
See Who Is Logged Into a Remote Computer: 6 Best Ways
October 26, 2025 - Open PowerShell on your local computer by typing PowerShell in the Search field. You have to establish a remote session with your remote system using the following command. Replace RemoteComputerName with the name of the remote computer.Enter-PSSession -ComputerName RemoteComputerName · After entering the remote session, use the following PowerShell command to know about the logged-in users.Get-WmiObject -Class Win32_ComputerSystem | Select-Object -ExpandProperty UserName