Friday, February 1, 2013

Determine which Remote Desktop Gateway server a user is connected to using the client's IP address

Determine the client's IP address
End user may need to Google search for "What is my IP address" to determine their Internet IP address

Download PSEXEC.EXE
http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

Create and populate a SERVERS.TXT file
Create a file named SERVERS.TXT and add the server names of your Remote Desktop Gateway servers


Place PSEXEC.EXE, SERVERS.TXT, and the following script in the same folder

@echo off

for /f %%x in (servers.txt) do (
   echo.
   echo.
   echo.
   echo Current target: %%x
   PSEXEC.exe \\%%x -w C:\windows\system32 netstat -n>NETSTAT-%%x.TXT
   )
pause

Run the script

Search the output files for the client's IP address
type netstat*.txt | find /i "client's IP address"