Solved

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

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

803 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