The script below lists all users that have open RDC sessions on a list of servers.I need it to just list any from a specific person. Could anyone help...
$servers = get-content “C:\scripts\servers.txt”
foreach ($server in $servers)
$command = “quser /server:” + $server
Should probably take a look at this:
Why re-invent the wheel?
This is helpful, but it doesn't really answer the question.
You could do something like below. The unfortunate thing is that quser doesn't know how to quietly tell you a user in NOT logged on, that is, the error message in PowerShell is pretty ugly.
That does list just the one username, but now it doesn't show the servername. example:
USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME
cfranks rdp-tcp#0 2 Active 4 7/23/2014 11:30 AM
That's pretty simple. Add this line above the quser line:
"----- $computer -----"
that worked perfectly thanks..
Is there any way to add a Log Off command to this script?
im rubbish at scripting - hence on here trying to learn but.....
using the quser output above you just need the sessionID, and this command:
logoff 2 /server:servername
hopefully someone else on here can say how to do it as that would be useful for me too.....if not give me 6 months or so.
Powered by IDERA