Title: Commandline control of Terminal Services
1Command-line control of Terminal Services
2Webcast Schedule
-
- Todays event will run one-hour long. Here are
the expected times for each segment of the
Webcast -
- 00 05 Moderator introduces the speaker and
discusses the details of the Webcast. - 05- 25 Speaker delivers a PowerPoint
presentation on the Webcast topic. - 25- 35 Moderator and speaker engage in a brief
QA on the topic - 35- 60 The speaker responds to questions
submitted by the audience. - You can submit questions to the speaker at any
time during the event. Just click on the Ask a
Question button in the lower left corner of your
screen.
3Technical FAQs
- Q Why cant I hear the audio part of the
webcast? - A Try increasing the volume on your computer.
- Q I just entered the webcast and do not see the
slide that the speaker is referring to. What
should I do? - A The slides are constantly be pushed to your
screen. Youll should refresh (hit F5) to view
the latest slide. -
- Q What time zone do the webcasts take place?
- A The TechTarget webcasts all occur on Eastern
Daylight Saving Time (UTC/GMT - 4 hours). - Q. I cant view some of the detail on the slides.
How do I enlarge the slides for a better view? - A Click the Enlarge slide link in the upper
right corner of your presentation. This will open
a new browser with a full view of the current
slide. - You can also visit the Broadcast Help page for
more information or to test your browser
compatibility. Click here http//audience.broadc
ast.yahoo.com
4Agenda
- Why is command-line editing useful?
- What tools are available for command-line
editing? - Using TSCMD.EXE for simple configuration
- Using WMI and VBScript for more advanced
configuration
5Why Command-Line Editing?
- Editing settings from the GUI is time-consuming
on more than a few servers - Command-line edits can be scripted and are
therefore more consistent. - Command-line edits dont need to be done either
at the console or by using a TSCAL to connect to
the terminal server to be edited
6What Tools Are Available?
- Command-line configuration tools in Terminal
Services - TSCMD.EXE
- The new WMI provider for Terminal Services
7Using TSCMD
- Command-line support for common Terminal Services
settings, based on a WTS API - Requires Windows 2000 or later on client and
server - Edit the settings on the server where the
settings are stored (e.g., domain controller) - Basic TSCMD syntax
- tscmd New Value
8Using TSCMD.EXE
- Works across the network
- Point it to the terminal server and user account
you need to configure - Returns net error messages, so if you get an
error run net help to troubleshoot - Settings take place immediately for the next user
sessionno need to reboot. - To make TSCMD.EXE report existing settings, run
the command with no new value
9TSCMD.EXE Settings
- InitialProgram
- WorkingDirectory
- InheritInitialProgram
- AllowLogonTerminalServer
- TimeoutConnection
- TimeoutDisconnect
- TimeoutIdle
- DeviceClientDrives
- DeviceClientPrinters
- DeviceClientDefaultPrinter
- BrokenTimeoutSettings
- ReconnectSettings
- ModemCallbackSettings
- ModemCallbackPhoneNumber
- ShadowingSettings
- TerminalServerProfilePath
- TerminalServerHomeDir
- TerminalServerHomeDirDrive
10Disabling User Access
tscmd sandworm scott allowlogonterminalserver 0
11Editing Remote Control Settings
tscmd sandworm scott shadowingsettings 1
12Configuring Printer Settings
tscmd sandworm scott deviceclientprinters 1
tscmd sandworm scott deviceclientdefaultprinter 1
13Configuring Timeouts and Reconnects
tscmd sandworm scott timeoutconnection 100 tscmd
sandworm scott timeoutdisconnect 200 tscmd
sandworm scott timeoutidle 120
14Starting a Program in the Session
tscmd sandworm scott initialprogram
wordpad.exe" tscmd sandworm scott
workingdirectory c tscmd sandworm scott
inheritinitialprogram 0
15Limitations to TSCMD.EXE
- Functions on a per-user and per-server basis only
- Not all settings exposed through this API
- Requires the person running the command to be an
administrator - Very limited error reporting
- No built-in event logging
16Using VBScript to Edit Settings
- The Windows Scripting Host allows you to run
VBScript from within the operating system - Windows Server 2003 has a new WMI provider that
allows you to edit settings programmatically,
using VBScript
17What can VBScript Do that TSCMD cant?
- Heres a short list
- Configure color depth for the session
- Adjust mandatory encryption settings
- Define the session directory location
- Configure Time Zone redirection
- Disadvantage it takes longer to learn. Knowing
TSCMD can be helpful for learning some values
edited through WMI
18Parts of a Script
- Actions you can take
- Things you can act on
- Statements defining the conditions under which
youll take those actions
19Data Types
- Numbers
- Strings
- Date/Time data
- Boolean values
20Variables and Constants
- Both have assigned valuesuser input, object
properties, or calculations from another part of
the script - Variable values may change in the course of the
script - Constant values do not change
21Arrays
- Groups of variables, as many as you like when you
define the array - Array sizes may be static or dynamic
- Can contain any data type numbers, strings,
date/time information, etc. - Find data by its index number (beginning with 0)
- Arrays may have more than one index, but more
than two gets confusing
22Built-in Functions
- Combined sets of instructions for doing things
that are hard to do with the operators supported
in VBScript - Several different kinds
- String functions
- Date and time functions
- Array functions
- Working-with data types functions
- Mathematical functions
- Other functions (InputBox, MsgBox)
23String Functions
- Character/ANSI conversion and checking
- String Size
- String Editing
- Replacing text in a string
24Date and Time Functions
- Returning date and time information
- Converting string data to a date/time
- Returning and computing the date and time
25Numeric Functions
- General mathematical functions
- Rounding functions
- Random number generators
26Array Functions
- Join merges arrays
- Split divides arrays
27Functions for Working with Data
- Determining data type
- Conversion functions
- Formatting
28Other Functions
- Input and output boxes
- Error handling/notification
- Determining engine version
29Statements
- If Then
- Select Case
- Do Loop
- For Next
30Basics of WMI
- WMI exposes underlying parts of the operating
system to scripting languages such as VBScript.
If a part is exposed, its said to have a
provider. - You cannot access settings without a provider.
- To edit a setting on a remote computer, that
computer must support WMI and must have the
provider the script refers to.
31Terminal Services Support in WMI
- The provider exposes TS-specific structures,
including - Sessions
- Session environments
- Remote control settings
- Logon settings
- To edit the settings, you enumerate the instances
of these objects on the selected server
32ADSI Objects
- To get to the servers, youll often use ADSI
- Any object found in a directory structure
- User accounts, organizational units, domains,
printers - Uses same property and method structure as WMI or
file system objects - Not limited to Active Directoryworks also for
SAM and NDSbut namespace and syntax varies with
the type of information you need
33Key ASDI Functions and Methods
- GetObject function connects to an object so you
can access its properties and methods - GetInfo queries the directory structure and
repopulates the local cache - Put sets a property in the local cache
- SetInfo writes the cached value to the original
object
34Running a Script on Multiple Servers
- Connect to the OU in which all terminal servers
reside and run the script on all members of that
OU - Store the names of all terminal servers in a file
and input that file into the script - Accept server names as arguments to the script
35Scripting Tips
- Keep the lines in scripts short
- Comment liberally
- Mix case in your code to enhance readability
- Use the WSH command-line environment
- Name variables and constants according to data
type - Explicitly define variables
- Write scripts in a text editor
36Summary
- Use command-line tools to edit terminal settings
more quickly and consistently - TSCMD.EXE for basic configuration
- VBScript and WMI for more complex settings
(Windows Server 2003 only)
37Need More Information?
- TSCMD.EXE is a free download from
http//www.systemtools.com/free_frame.htm - Brief user guide to TSCMD.EXE at
http//www.termservhub.com - My Scripting Solutions column in Windows and
.NET Magazine offers step-by-step explanations of
VBScript, WMI, and ADSI - Check out Microsofts script center at
http//www.microsoft.com/technet/treeview/default.
asp?url/technet/scriptcenter/default.asp