Powershell GUI – Logging off multiple users in a RDSH Collection!

Problem: I wanted to log off multiple users from an RDSH collection. First I tried the local task manager from the server, that only allowed one selection in server 2012 r2. Then I tried the remote desktop collection in server manager, that only allowed me to log off one user as well. I wanted lower level techs to be able to do this easily. So I wrote a small powershell script that uses out-gridview to create a small GUI.

The script

import-module RemoteDesktop
Get-RDUserSession -ConnectionBroker connectionbroker.domain.local | select username, hostserver, unifiedsessionid | Out-GridView -title "Select users to log off" -passthru | Invoke-RDUserLogoff -force

The GUI

img 57b25164d1cd3

How to use it?

Just copy and paste the script and save it as filename.ps1, then just run it! (make sure you have your execution-policy set appropriately)

 
At the bottom of the gui you will see a “OK” button that will log off all the highlighted users.

Leave a comment

Exit mobile version