Ask user to logoff or just close RDP session

Ask user to logoff or just close RDP session

avatar

At our IT Department we use RDM Enterprise v2021.2.20.0. I'm looking for a way to logoff the RDP session on the host when the user closes the session. I know RDM can handle this by changing the option "Automatically log off when disconnecting". This would work except for the fact that sometimes users just want to close the RDP session and reconnect later in time.

So basically I'm lookin for a way ask the user to keep the session active. My idea was to create an "on disconnect" powershell event that will show a popup message with an OK and a Cancel button. When the user hits OK or the script timed out on waiting for user input, the session will be logged off. If the user hits Cancel the session will close and not logged off.

This is my powershell code:

$Message="Your remote session will automatically logoff after 5 seconds. Hit cancel to close and keep Remote session active."
$Title = "Automatic Remote Session Logoff"

$sh = New-Object -ComObject "Wscript.Shell"
$intButton = $sh.Popup($Message,5,$Title,1+64)

if ($intButton -lt 2) {
    ## LOGOFF RDP SESSION ##
}


I'm struggling with the part ## LOGOFF RDP SESSION ##. I was hoping that the Powershell Module of RDM could achieve this but I couldn't find how. Hopefully you can give me some hints on how to achieve this. With or without the Powershell event.

All Comments (5)

avatar

Hello Jasper,

Unfortunately, there is no "on disconnect" event, and if we place it in the "Before Close" event, the disconnect of the session will have already occurred.

I would recommend posting in the feature request forum: https://forum.devolutions.net/forums/17/remote-desktop-manager--feature-request to ask if it is possible to add a prompt option in the "Automatically log off when disconnecting":
forum image

Best regards,

Richard Boisvert

avatar

Hay Jasper, we do something similar here where, most of the time, when our users close an RDM tab they want to log off the session. Our RDM is configured to automatically log off when disconnecting. In those times where they want to keep the session running, they disconnect from within Windows by clicking the Start Menu, Click on the Power icon and click Disconnect.

forum image

While it is more clicks than if RDM prompted, our users have accepted this as a solution.

avatar

Hi Guys,

Thank you both for your response. I will post this as a feature request.
For the meantime another question which maybe make this possible. Can the RDM agent somehow help me with this?

avatar

Hello Jasper,

Thank you for your swift reply!

The RDM Agent won't allow you to achieve this. The method mentioned by Paul07 or implementing a new feature would be the best course of action.

Best regards,

James Lafleur

avatar

Hi Guys,

Just to let you know, I achieved my goal with advanced powershell scripting. I used invoke-command and also needed to convert the $RDM.Username & password into a PSCredential object.

Eventually I ended up by using the method mentioned by Paul07. Thanks for that suggestion, @Paul07