LazyTS is a PowerShell script to manage Sessions and Processes on local or remote machines. It allows you to Query/Disconnect/Stop session(s), Query/Stop process(es) and Send Interactive message to one or more sessions.
This tool is using the module PSTerminalService which relies on the Cassia .NET Library.I used Sapien PowerShell Studio 2014 to which make life easier if you want to start building WinForms tools and add PowerShell code.
Version
- 1.1 Update
- Add support for RDP Shadow (View and Control)
- Add small highlighting util
- Fix some minor bugs
![]() |
Highlighting util |
![]() |
Remote Desktop (Shadow View and Control) |
- 1.0 Initial version
- Features
- Session Management: Query/Disconnect
- Stop
- Processes Management: Query/Stop
- Message : Send message to Session(s)
Requirements
- PowerShell 3.0
- Cassia Library (included in the download)
LazyTS is relying on the Cassia .NET Library (A DLL file). This file need to be present in the same directory as the script (Either when you use the PS1 or EXE file)
Of course you also need the appropriate permission on the remote machine to be able to manage it.
If the Cassia.dll is not present, the script won't start:
Download
Features
Querying session on local or remote machines
Disconnecting Session(s)
Select one session or multiple sessions and right click, click on Disconnect SessionThis will only disconnect the user, its session State will become "disconnected", but will remain opened on the host.
When getting disconnected, the user will get the following window
![]() |
Your Remote Desktop Services session had ended. Your network administrator might have ended the connection. Try connection again, or contact technical support for assistance |
Stopping a Session(s)
Select one session or multiple sessions and right click, click on Stop SessionThis will close the session of the user without warning. Any current work in progress will be lost.
Here is the confirmation window after you select "Stop Session"
![]() |
Querying Processes
After entering the ComputerName, click on the button Process.This will list all the running processes (for all sessions)
Stopping Process(es)
Select one process or multiple processes and right click, click on Stop ProcessThis will Stop the process(es) selected.
![]() |
Confirmation Window |
Sending Message(s)
After entering the ComputerName, click on the button Message.Note that you must select one session or one process in order to use this option (the script need to know which session(s) it should send the message to.
This will Send a message to the selected session. If multiple sessions are selected only one message will be sent to each session.
![]() |
Confirmation windows |
![]() |
Message to send |
Example of message received by each session selected
Remote Desktop: Shadow
When right clicking on a row you'll have the possibility to open a Shadow RDP on a selected Session ID. After you request to View or Control the session, the user will get this message![]() |
"<Domain>\<samaccountname> is requesting to control your session remotely. Do you accept the request" Message showed to the user when trying to control his session id. |
If the user deny the request, you'll get the following message
![]() |
"The operator or administrator has refused the request" |
Using the tool
Launching the tool from the PS1
Launching the tool from the EXE
Frequent issues
Loading Error: Unable to find type [Cassia.Impl.TerminalServicesSession]. Make sure that the assembly that contains this type is loaded.
Verify that you have at least PowerShell version 3.0
Verify and Unblock the files if needed
When you download file from internet they are blocked by default.
Unblock the zip before you extract the content or unblock each files
LazyTS.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
Verify you PowerShell Execution Policy
If you are using the ExecutionPolicy 'Restricted', you might get this error.
See the link below to help you choose the appropriate Policy. (in my case I user RemoteSigned)
http://technet.microsoft.com/en-us/library/hh847748.aspx
"Exception calling "Set_Item" with "2" argument(s): "Cannot set Column 'CurrentTime' to be null. Please use DBNull instead.""
Solution: This is fixed in the last update of v1.1. Download from TechNet or GitHub"This computer name is invalid"
![]() |
This Computer name is invalid |
Great tool! Would it be possible to download the source files (i.e. the psf file and other associated files)? I use Sapien PowerShell Studio 2014 and would like to add a few custom commands to LazyTS for my own environment.
ReplyDeleteThanks
Thanks for your comment Sam, just curious, what type of commands do you want to add ?
DeleteI would be interested in this as well. I would like this so I can try to figure out a way to have it query Multiple Servers and search for $UserName so kind of backwards of what it does now.
DeleteWonderful work btw!! You go it going on! killing my self here trying to reverse engineer to customize for my need. Love it anyway, don't have much of a need to query just one server so want to customize it so I can use it :)
Kudos Francois Kudos. And thank you for sharing your hard work so we can use and even more importantly Learn from you!!!
We have a particular legacy application in our environment that causes a lot of issues, which we usually have to fix by deleting individual user profiles from our RDS servers. I already have a tool that I made in Powershell Studio that I use to do this, but I'd like to have all of my RDS tools in one place. I also have a few other scripts that I use for various maintenance tasks. For example, I'd like to expand the Message functionality to include the ability to disable new logons, and to reboot the server at a specific time, so that when I'm going to perform maintenance on a server, I can disable new logons, ask users to log out and back in again, and reboot the server.
ReplyDeleteAwesome tool! Any way to display more than one server?
ReplyDeleteThanks for your comment.
DeleteThe tool does not support multi server at the moment.
Would it be a big plus ? how many server would you typically query ?
Multiple servers would be a HUGE plus. I have 10 - 20 servers that I need to manage. MS default GUI (Server Manager) us useless as you can only interact with a single user at a time.
DeleteHi Damian,
DeleteAlright, I will look into this. Not sure how to proceed since I don't want the GUI to be slow by querying 20 servers at the same time.
Thanks for your feedback
I'll second the multiple servers request. If it could be an option, thinking input file, I think a slow query should be expected. Have a couple thousand servers here and would love to have an option like this. I love your tool for a quick server check but currently using a qwinsta output (which, as expected, takes a good while to run) to see what the environment looks like.
DeleteHi, Francois! Great job, but... one more request for multiple servers. It will be asewome to see all my TS servers in one GUI.
ReplyDeleteThanks for the feedback!
Delete