List RDP Users
› Forums › Desktop Info › List RDP Users
Tagged: powershell
- This topic has 6 replies, 1 voice, and was last updated 2 years ago by
Glenn.
-
AuthorPosts
-
-
19 August, 2020 at 9:28 pm #3293
Brad
I see in desktopinfo’s manual there is a RDS and RDSSESSIONS item but I’ve been playing around with both of them and I can’t seem to find a way to get either of them to output a list of users connected via RDP.
What I am looking for is output similar to if you open task manager, and go to the users tab. So I want output like:
ID User Status
#1 bob connected
#2 susan connected
#3 jane disconnected
#4 dick connectedWhere # is the RDP session ID number, bob/susan is the users username, and connected or disconnected is if they are connected or disconnected from RDP.
The idea is that if we have multiple people working on the same box they may want to be aware of one another (in case two people are responding to a problem at the same time). It’s also useful to see who else is logged in if all the RDP sessions are taken up.
Of course its possible to open task manager to find this information but it would be handy to have it viewable at all time in desktop info. I’ve managed to do this with bginfo but calling a VBS script.
I can’t seem to figure out a way to make DesktopInfo call an external script nor can I figure out a WMI query that returns the desired information. Am I missing something?
Thanks,
Brad -
20 August, 2020 at 5:47 am #3296
Brad
We figured out how to do this.
For other benefits, you can run powershell scripts with the CMD item.
What we ended up with isn’t precisely what we wanted but it seems that column based output only looks decent if you use a monospace font (and I don’t care for the look of the monospace fonts with Desktop Info). Out of curiosity does Desktop Info not support font smoothing?
Hopefully this helps someone else though:
In DesktopInfo.ini:
123# RDP UsersCMD=text:RDP Users:,interval:600,code-page:65001,file:powershell.exe,parameters:.\rdp-users.ps1,display:%4,text-offset:20In rdp-users.ps1:
$output = $(quser) -Replace ">",""
$output = $output -Replace "\s{2,}","t"
$($output.trim() | convertfrom-csv -delimiter "t" | ft -Property USERNAME -HideTableHeaders | Out-String).Trim()-
20 August, 2020 at 9:35 am #3299
that script got mangled. can you repost it?
-
-
21 August, 2020 at 7:19 pm #3310
Brad
I saw that… unfortunately I don’t seem to be able to edit my post?
I would post again but I think the issue is that the forum is interpreting the “backtick t” (which is a tab in powershell) as an indicator that I’m trying to post code.
Is there some way to escape the backtick in the forum software?
-
22 August, 2020 at 7:20 am #3314
ok. yes, the backtick is a code block.
if i type a backtick and some text followed by a backtick i get a code block
\
if i type backslash backtick what do i get ? \
still creates a code block. i tried a couple of markdown plugins with no joy so i don’t know what the answer is apart from something obvious like manually inserting {backtick}
-
This reply was modified 2 years ago by
Glenn.
-
This reply was modified 2 years ago by
-
25 August, 2020 at 7:12 pm #3338
Brad
$output = $(quser) -Replace “>”,””
$output = $output -Replace “\s{2,}”,”{backtick}t”
$($output.trim() | convertfrom-csv -delimiter “{backtick}” | ft -Property USERNAME -HideTableHeaders| Out-String).Trim()(Replace {backtick} with an actual backtick)
-
30 August, 2020 at 8:24 am #3346
Looks good. I found I had to change the double quotes to single quotes to get it to run in the ISE but it still complained about unauthorized access when running from DTI. But then I don’t claim to know anything about Powershell.
-
-
AuthorPosts
- The topic ‘List RDP Users’ is closed to new replies.