Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2016-09-07
5
53 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 69

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 69

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 69

Accepted Solution

by:
Qlemo earned 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

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.
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

840 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