Link to home
Start Free TrialLog in
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
Avatar of SubSun
SubSun
Flag of India image

Avatar of Mark Holbert
Mark Holbert

ASKER

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
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.
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
Avatar of Mohammed Khawaja
Mohammed Khawaja
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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