Solved

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

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

Expert Comment

by:Qlemo
Comment Utility
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
Comment Utility
i have administrator rights,me other 3 persons, so i can't do that
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
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
Comment Utility
can u create a batch file pls?
0
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article shows how a content item can be identified directly or through translation of a navigation type. It then shows how this information can be used to create a menu for further navigation.
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now