Some background. We currently use RD for our users to access our main EMR. This way we offload the workload to Servers, not local machines.<\/p>\n
Anyway… one of the issues I run into is that sometimes, the session will hang. We cannot isolate the issue, but it happens periodically. While we work that out, right now our process is:<\/p>\n
log into the ConnectionBroker > Wait for the Host to populate > find the user > logoff the session remotely.<\/p>\n
I was playing with Powershell yesterday, I am a COMPLETE N00B when it comes to this, I recently returned to IT from a decade long trip as an installer. I was able to cobble together some Powershell commands to keep me from having to remote into the server.<\/p>\n
Currently I use: Get-RDUserSession -ConnectionBroker “Broker.office.local”<\/p>\n
This pulls a list of connected users.<\/p>\n
Then I identify the RD Server they are on, (out of 3) and the Unified Session ID and log it off using<\/p>\n
Invoke-RDUserLogoff -HostServer “appserver(number).office.local” -UnifiedSessionID (number) -Force<\/p>\n
While this is WAY faster than going into the server… I want to be able to parse the UserName, have it show me only the offending sessionID, so I can kill it automatically using the Username…<\/p>\n
Any Thoughts on how to create this script? my Google-Fu is weak today.<\/p>","upvoteCount":3,"answerCount":3,"datePublished":"2019-08-15T13:53:26.000Z","author":{"@type":"Person","name":"milerky2","url":"https://community.spiceworks.com/u/milerky2"},"acceptedAnswer":{"@type":"Answer","text":"
Check out the script this guy put together. Should suite your needs or at least give you a head start on a custom PS script.<\/p>\n