Script reveals which port Terminal Services listens to for incoming connections

Scripting expert Christa Anderson explains how to write a script that reveals which port Terminal Services listens to for incoming connections.

For many people, one simple yet frustrating problem is finding out which port Terminal Services is listening to for incoming connections.

The default is 3389, but people edit the default for security reasons (or sometimes merely out of curiosity), then can't remember whether they edited it or not. It matters, because if the clients aren't pointing to the right port when they attempt to connect, the connection will fail -- editing the port will affect future Remote Desktop Procotol packages, but not the ones you distributed before changing the port.

It also matters because no Terminal Services tools display or allow easy access to the listening port. (This may be because a terminal server can have more than one network card and, therefore, could conceivably be listening on two ports that would need to be configured separately. But this lack of easy access to the listening port is still inconvenient.)

Rather than walking around to each terminal server, or even opening the Registry Editor for each terminal server, you can write a script to check the value and display it in decimal (which for most people is easier to read than hex). To work properly, our script needs to read a Registry key; convert the value of that key from hex to decimal; and record the value of the key in the Event Log.


Scripting School: Turning the environment with WshShell
- Introduction
- Contents of WshShell
- Viewing and editing the Registry
- Reading and writing to the Registry
- Recording the change
- Summary

Read Christa's previous columns:
April 2005: Beginner's guide to scripting
May 2005: It's time to increase your scripting expertise
June 2005: Connect users to network resources
July 2005: More on connecting to network resources
August 2005: Find objects with Windows Scripting Host
September 2005: Windows Script Host arguments

ABOUT THE AUTHOR:
When Christa Anderson began working with Windows Server operating systems in 1992, she became increasingly interested in finding more efficient and flexible ways of performing routine tasks. Christa has written extensively about administrative scripting and taught technical sessions on the subject at conferences such as Comdex and CeBIT, helping people who had never done any scripting to write their own scripts in half a day. In addition to her interest in scripting Windows management, Christa is an authority on server-based computing and the program manager for Terminal Services licensing in Longhorn. If you have a scripting question for Christa, please e-mail her at scripting@SearchWinSystems.com.

Dig deeper on Windows Server and Network Security

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchServerVirtualization

SearchCloudComputing

SearchExchange

SearchSQLServer

SearchWinIT

SearchEnterpriseDesktop

SearchVirtualDesktop

Close