ICTwijs Automatisering & Consultancy
Achter 't Holthuis 34, 7391 TN Twello
Telefoon: 06-38812310 E-mail: info@ictwijs.nl
How to create a report of currently logged on RDP users to alll server's in a domain.
A techsupport employee had changed his password and complained about that his passsword was locked in Active Directory. After we unlocked the password, in minutes it was locked again.
I tought it had someting to do with old session, that are still connecting with the old password.
We deleted the manual created mappings, but that wasn't.
Now i wanted to know if the user was logged on to any servers that he wasn't aware of.
I created two scripts.
Script 1 (session.cmd)
set logserver="K:\tools\query-user-rdp-session\log\server.log"
set logsession= "K:\tools\query-user-rdp-session\log\session.log"
@echo on
echo Tip "logoff sessionid /server:" (example:logoff 20 /server:dc01) to logoff a user remotely> %logsession%
DsQuery Server -domain yourdomainname.local -o rdn > %logserver%
DSQUERY COMPUTER OU=srv,OU=Organisationname,DC=domain,DC=local -o rdn >> %logserver%
FOR /F "usebackq tokens=*" %%G IN (%logserver%) DO call sessionvar.cmd %%G >> %logsession%
notepad %logsession%
Exit
Script 1 (session.cmd)
query user /server:"%1"
Now i run session.cmd
The script created an output in notepad and i can search the users loginname with the find option in notepad.
I saw the user was still logged in on dc01 and had a sessionid of 20
To disconnect the user of te remote server is used the command:
logoff 20 /server:dc01
The user was connected to a whole bunch of servers, we disconnected all the sessions and the problem was solved.
ICTwijs
Achter 't Holthuis 34
7391 TN Twello
Tel: 06 - 38812310
E-mail: info@ictwijs.nl
Indien u teruggebeld wilt worden kunt u hieronder uw telefoonnummer achterlaten. Wij zullen dan zo spoedig mogelijk contact met u opnemen.
Een geheel vrijblijvende offerte of meer informatie aanvragen behoort ook tot de mogelijkheden. Vul hiervoor ons contactformulier in.
Commentaar