Avatar of Mark Holbert
Mark Holbert asked on

Logoff RDS 2008R2 disconnected Session via PowerShell script

I have a growing cluster of 4 2008R2 Servers setup as RDS Hosts in an environment with around 50 RDS users.  I need a quick way to address a blown RDS session via PowerShell, or similar.  

Ideally, I would be able to launch the script, input the session username and hit enter.  

Mark
PowershellWindows Server 2008

Avatar of undefined
Last Comment
Subash Sundharan

8/22/2022 - Mon
Subash Sundharan

ASKER
Mark Holbert

I need to run the script from a PowerShell app on my iPhone.  Lots of Doctors, no time to go to an actual computer to address an issue.  

I'm looking for quick and dirty but efficient.

Mark
Mohammed Khawaja

Can't you establish RDS and run quser to check disconnected users and then use logoff xx (xx is the session ID) to log off the users.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER
Mark Holbert

If I was smart enough to do that, sure.  Seriously though, I'm thinking what you can code in 10 minutes, would take me days to get close to.  I learn from your script and hopefully tweak it to a vague understanding.  

Mark
ASKER CERTIFIED SOLUTION
Mohammed Khawaja

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Subash Sundharan

If you have enabled PSRemoting then, you can use Invoke-Command to run the commands remotely.. For example..
Invoke-Command -ComputerName ServerA -ScriptBlock {CMD /c 'For /F "Tokens=*" %a in (c:\Servers.txt) Do Logoff ID_Number /Server:%a'}

Open in new window