Script to Logout all Users Before Restarting RDS Servers
Multiple vendors have recommended logging out all users before restarting our RDS servers. Sadly I was never able to find a script that could do everything I wanted. I created the script below for Server 2012 + servers. The script will do the following: Logout all active users (even console users) Write errors and information into the Application event log You can find the script here: https://github.com/andy2002a/PowerShell/blob/master/RDS/Disconnect-LoggedOnUsers.ps1 The script will not reboot the server, but you can always add a shutdown -r -t 0 at the end, or schedule your reboot script to run right after this one.