Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to see when and who log off my rdp session?and how to block that?

Posted on 2016-09-07
5
Medium Priority
?
65 Views
Last Modified: 2016-09-10
First of all i wanna know how to block,hide anyone to end my rdp session ,also.........mmm  i wanna know if there is a solution to see who log off my rdp session?any command for powershell?can anyone help me?thank you
0
Comment
Question by:john lambert
  • 3
  • 2
5 Comments
 
LVL 71

Expert Comment

by:Qlemo
ID: 41787386
If you need to have RDP allowed, all you can do is to disallow login for anybody else, by removing the Interactive Login privilege.
0
 

Author Comment

by:john lambert
ID: 41787397
i have administrator rights,me other 3 persons, so i can't do that
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 41787522
There is no way on a client Windows OS. A server OS is different, if different users are used. But a client OS only allows one active login (RDP) at any time, others are suspended (if Fast User Switching is allowed, otherwise logged off) after notice.
If the same login is used, the session is taken over without notice, even if the original RDP session is still active and connected.

For scenarios where multiple user are able to connect to a single machine with the same user in our company, I have set up a remote test for active RDP session, and stopping the connect attempt if there is one. This requires to run a batch file instead of mstsc.
0
 

Author Comment

by:john lambert
ID: 41787572
can u create a batch file pls?
0
 
LVL 71

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 41788286
You are required to be able to map a network drive to the RDP target without having to provide login data.
Also psExec from www.sysinternals.com has to be available in the same location as the batch file.
I've hard-coded the RDP target if not provided on the command line when calling the batch file (variable PC).
@echo off
setlocal EnableDelayedExpansion
set pc=%1
if "%1" == "" set pc=MaintenancePC
for /F "tokens=3,4 delims=: " %%C in (
  '2^>nul %~dp0psexec \\%pc% cmd /c netstat ^| findstr /i /R /c:" *TCP *.*:3389 *.*:" /c:" *TCP *.*:ms-wbt-server *.*:" ^| findstr /v /l "localhost [::1] 127.0.0.1" '
) do (
  echo      *** Currently connected to %pc%: %%D
  set rdpconn=no
  pause
)
if not defined rdpconn start "" mstsc /v:%pc%

Open in new window

psExec allows to hard-code login if required, but then you'll have to provide the plain text password in the script.
2

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A brief introduction to what I consider to be the best editor for PowerShell.
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Loops Section Overview

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question