Find computernames connected to a RDP server

Thomas Albertini 1 Reputation point
2022-08-18T08:29:48.897+00:00

Hello,

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.

Thanks

Thom

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

2 answers

Sort by: Most helpful
  1. Limitless Technology 39,511 Reputation points
    2022-08-18T15:39:53.607+00:00

    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:210.168.1.54

    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:210.168.1.54

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

    The following command exports the output to CSV file.
    (Query user /server:210.168.1.54) -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
    2022-08-19T06:53:25.97+00:00

    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

    SESSIONNAME USER NAME SESSION ID STATE HOST NAME

    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