close all RDP sessions for all servers only, found in AD

Welcome Forums General PowerShell Q&A close all RDP sessions for all servers only, found in AD

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years ago.

  • Author
  • #6225

    Points: 0
    Rank: Member

    by rthilo at 2012-12-06 10:39:11


    Up to now I used CMD or Autoit Scripting to reset RDP Sessions for Servers, using the buildin local scheduler. (qwinsta.exe + rwinsta.exe)

    I'm just wondering, if there might be an approach to consolidate this, so that it can be done from one PC/Server, that's quering AD for all servers, then get a list for all RDP sessions of these servers, then reset (forced) all of them.

    RDP sessions to workstations shall remain untouched.

    To get all servers in AD is not an issue. But how to get the RDP sessions, and how to reset them using PowerShell?

    get-QADComputer | ?{$_.OSName -match "server"}|ft name, osname -auto

    Any suggestions appreciated.

    by coderaven at 2012-12-06 10:56:40

    I have been using the PSTerminalServices Module hosted here.

    I think that is what you are looking for.

    by rthilo at 2012-12-06 11:50:25


    Thanks for your reply. Yes, this ....

      PS > Get-Command -Module PSTerminalServices

      CommandType Name Definition
      ———– —- ———-
      Function Disconnect-TSSession ...
      Function Get-TSCurrentSession ...
      Function Get-TSProcess ...
      Function Get-TSServers ...
      Function Get-TSSession ...
      Function Send-TSMessage ...
      Function Stop-TSProcess ...
      Function Stop-TSSession ...

    ... looks like it's exactly what I was looking for.


The topic ‘close all RDP sessions for all servers only, found in AD’ is closed to new replies.