Wednesday, November 11, 2009

(轉貼) Terminal Services Command Line Administration

Terminal Services Command Line Administration


Managing your Windows 2003 Terminal Server can be done faster and easier with a few simple command line tools. There are a lot of them so hang on!


Change User - When installing applications on a terminal server you must be in Install Mode. To toggle the system between Install and Execute Modes, you can use the Change User commands.


To switch to Install Mode: CHANGE USER /install


To switch to Execute Mode: CHANGE USER /execute


Change Logon - To quickly disable or enable the ability to logon to the terminal server you can use the Change Logon command. This will not affect currently logged on users.


To enable new logons: CHANGE LOGON /enable


To disable new logons: CHANGE LOGON /disable


Query TermServer - Lists all terminal servers in the current domain.


QUERY TERMSERVER [/domain:domain] [/address][/continue]




  • /domain:domain - specifies the domain (current logged on domain is default)

  • /address - lists the IP address of the terminal server

  • /continue - removes the pause between ouput screens


Query Session - Lists all current sessions running on a terminal server.


QUERY SESSION [sessionname | username | sessionid][/server:servername] [/mode] [/flow] [/connect] [/counter]




  • sessionname is the name of the session that you want to query

  • username is the name of the user you want to query

  • sessionid is the ID of the session you want to query

  • /server:servername is the name of the server you are querying

  • /mode outputs the current line settings

  • /flow outputs the current flow control settings /connect outputs the current connection settings

  • /counter outputs the counter information for the server


Query User or Quser - Lists all current users on a terminal server


QUERY USER [username | sessionname | sessionid] [/server:servername]




  • sessionname is the name of a specific session that you want to query

  • username is the name of the specific user you want to query

  • sessionid is the ID of the specific session you want to query

  • /server:servername is the name of the server you are querying


Query Process - Lists all processes running on the terminal server.


QUERY PROCESS [ x | processid | username | sessionname | /id:nn | programname] [/server:servername] [/system]




  • x lists information on all processes (note - replace x with an asterisk)

  • processid lists information about only the specific process ID

  • username lists processes running under the context of a specific user

  • sessionname lists processes running under the context of a specific session

  • /ID:nn lists processes running in the session with the specified session ID number

  • programname lists all processes started by the specified executable

  • /server:servername is the name of the server you are querying—the default is the server you are logged on to

  • /system lists processes running under the system context


TSShutdn - Will shutdown/reboot the terminal server after a specified delay.


TSSHUTDN [wait_time] [/server:servername] [/reboot] [/powerdown] [/delay:logoffdelay] [/v]




  • wait_time is the number of seconds to wait after notifying the users that the terminal server is about to shut down before forcibly logging them off (the default is 30 seconds)

  • /server:servername is the name of the server to reboot/shutdown (the default is the server to which you are connected)

  • /reboot reboots the server

  • /powerdown powers down the server after Windows has shutdown; the servers BIOS must support this command

  • /delay:logoffdelay the number of seconds to wait after logging out all users before shutting down the system (the default is 30 seconds)

  • /v displays verbose information about actions being performed


Logoff - Will logoff the specified user off the terminal server and close the session. Caution, if you don't specify a user it will log you off!


LOGOFF [sessionid | sessionname] [/server:servername] [/v]




  • sessionid is the ID of the session you want to logoff

  • sessionname is the name of the session you want to logoff

  • /server:servername specifies the name of server on which the session you want to logoff is running

  • /v displays verbose information about actions being performed


Reset Session - Will kill the specified users session without warning which can be useful when a users session is stuck. Caution, if you don't specify a user it will kill your session!


RESET SESSION [sessionname | sessionid] [/server:servername] [/v]




  • sessionid is the ID of the session you want to logoff

  • sessionname is the name of the session you want to logoff

  • /server:servername specifies the name of server on which the session you want to logoff is running

  • /v displays verbose information about actions being performed


MSG - Will popup a message on the specified user(s) terminal server session.


MSG [username | sessionname | sessionid | @filename | x ][/server:servername] [/time:seconds] [/v] [/w] message




  • username is the name of the user to whom you are sending the message

  • sessionname is the session name to which you want to send the message

  • sessionid is the ID number of the session to which you want to send the message

  • @filename is the name of a text file containing usernames, sessionnames, or session IDs to which you want to send the message

  • x sends the message to all users on the current or specified server (note - replace x with an asterisk)

  • /server:servername specifies the server where recipients of the message are connected

  • /time:seconds the number of seconds to display the message before the popup closes itself

  • /v displays information about the message as it is sent

  • /w causes the popup window to wait for the user to click OK before closing message is the text of the message to send


Shadow - Will allow you to shadow or take control of a users session.


SHADOW [sessionname | sessionid] [/server:servername] [/v]




  • sessionid is the ID of the session you want to logoff

  • sessionname is the name of the session you want to logoff

  • /server:servername specifies the name of server on which the session you want to logoff is running

  • /v displays verbose information about actions being performed


TSProf - Will update, copy or display the Terminal Server users profile path and/or data.


TSPROF /update [/domian:domainname | /local] /profile:path username TSPROF /copy [/domian:domainname | /local] [/profile:path] src_user dest_user TSPROF /q [/domian:domainname | /local] username




  • /update populates the user domainname\username’s Terminal Services profile path

  • /copy copies the Terminal Services profile from the source (src_user) to a different user (dest_user)

  • /q displays the Terminal Services Profile path for the specified user



原文網址:


http://thelazyadmin.com/blogs/thelazyadmin/archive/2005/06/24/Terminal-Services-Command-Line-Administration.aspx

Print Friendly and PDF
Share/Bookmark

No comments:

Post a Comment