Link to home
Start Free TrialLog in
Avatar of jskfan
jskfanFlag for Cyprus

asked on

Termical Services connection.

Termical Services connection.

I need a script that shows me in which computer a ceratin account has logged on through RDP.
Most of the time a user or myself remote to a computer and forgot to logoff.

Checking my sessions with a script would help to locate the computers my acount is logged on to.

Thanks
SOLUTION
Avatar of Neil Russell
Neil Russell
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jskfan

ASKER

<<<Could you expand on the scenario? You want one script to search Lots of servers for a certain RDP login user, is that correct?>>>

Correct.
Are you talking generically about computers or just servers? If servers terminal servers or any old server? If this could be ANY PC on your network you could be there a while depending on the size of your network.
Avatar of jskfan

ASKER

I am talking abou just servers.
By the way I used psloggedon.exe from Pstools, and output to the text file, but it showed my account logged on to some computers but when I verified it didn't
Add the below to the logon bat file of any user you want to track, please note the path variables at the very end of the script.
FOR /F "TOKENS=2* DELIMS=:" %%A IN ('IPCONFIG /ALL ^| FIND "IP Address"') DO FOR %%B IN (%%A) DO SET IPADDR=%%B
FOR /F "TOKENS=2* DELIMS=:" %%A IN ('IPCONFIG /ALL ^| FIND "Host Name"') DO FOR %%B IN (%%A) DO SET netbiosname=%%B
FOR /F "TOKENS=2* DELIMS=:" %%A IN ('IPCONFIG /ALL ^| FIND "Physical Address"') DO FOR %%B IN (%%A) DO SET macaddress=%%B
echo logon,%DATE%,%TIME%,%username%,%COMPUTERNAME%,%CLIENTNAME%,%netbiosname%,%ipaddr%,%macaddress% >> \\<servernamehere>\hiddensharehere$\%USERNAME%.csv

Open in new window

Avatar of jskfan

ASKER

do you mean I will create an OU put a user inside the OU then create a new group policy and put the batch file in the policy???
is the batch file I am creating is just copy and paste from the code you have written or there is anything to change?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
leave the username part.. thats  a variable that will write to a file named as the user logon name.csv
Avatar of jskfan

ASKER

<<usually i assign the logon script in the ADUC mmc in the profile area, then just drop the bat file in the netlogon share on the DC.>>

If I drop the bat file in the netlogon share on the DC, the script will be ran for every user who logs on.
Avatar of jskfan

ASKER

the script didn't work....

is psloggedon.exe from PStools good to use in this scenario?