Find computernames connected to a RDP server

Thomas Albertini 1 Reputation point


On a Windows Server 2019 i'm looking for solution to export or display the computer name of every RDP connexions.

The aim is to revoke some TSE licence by host.



Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,030 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 39,331 Reputation points

    Hi ThomasAlbertini-2349,

    Using Powershell, you can get a list of remote desktop sessions using the commands QWinsta and Query.

    List Remote Desktop Sessions using QWinsta:
    QWinsta /server:[Server name or IP]

    Replace the parameter [Server name or IP] with the name or IP address of the remote machine.
    QWinsta /server:

    Get Remote Desktop Sessions using Query:
    Query user /server:[Server name or IP]

    Replace the parameter [Server name or IP] with the name or IP address of the remote computer.
    Query user /server:

    You can use the below powershell command to get clear output.
    (Query user /server: -replace 's{2,}', ',' | ConvertFrom-Csv

    The following command exports the output to CSV file.
    (Query user /server: -replace 's{2,}', ',' | ConvertFrom-Csv |
    Export-CSV "C:\RDPSessions.csv" -NoTypeInformation -Encoding UTF8


    --If the reply is helpful, please Upvote and Accept as answer--

  2. Thomas Albertini 1 Reputation point

    Hi !!
    Thank you for your great help !

    I'm sorry but it seem i don't get info i want

    I thgought swinsta /VM could do the JOB because there is a HOST NAME column but it stays empty

    qwinsta /VM


    0 Services 0 Déco
    1 Console 1 Conn
    2 anUser 2 Déco
    3 anothUser 3 Déco

    those commands you gave me, lists users connected where i need to know the host associated to them.

    0 comments No comments