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
Mark HolbertAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SubsunCommented:
0
Mark HolbertAuthor Commented:
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
0
Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
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.
0
ON-DEMAND: 10 Easy Ways to Lose a Password

Learn about the methods that hackers use to lift real, working credentials from even the most security-savvy employees in this on-demand webinar. We cover the importance of multi-factor authentication and how these solutions can better protect your business!

Mark HolbertAuthor Commented:
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
0
Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SubsunCommented:
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

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.